
Python & IronPython . An introduction to Python and using IronPython on the .NET Framework Rasmus Nielsen ([email protected]) IT University of Copenhagen March 1, 2010 . Rasmus Nielsen ([email protected]) Python & IronPython What is Python? Python is named in honour of Monty Python Python is an interpreted, dynamically typed, high-level language Python combines remarkable power with very clean, clear, and spare syntax Python is a multi-paradigm language supporting: Object-oriented programming Procedural programming Aspect-oriented programming Functional programming Metaprogramming . Rasmus Nielsen ([email protected]) Python & IronPython Similarities to Java and C] Typically compiled to bytecode, but compilation is implicit Everything inherits from “object” INCLUDING: numbers functions classes . – everything is “first-class” Vast, powerful standard library Garbage collection Introspection / reflection Serialization Parametric polymorphism (Generics) Threads . Rasmus Nielsen ([email protected]) Python & IronPython Similaries to C The Spirit of C ..1. Trust the programmer. ..2. Dont prevent the programmer from doing what needs to be done. ..3. Keep the language small and simple. ..4. Provide only one way to do an operation. ..5. Make it fast, even if it is not guaranteed to be portable. Rationale for International Standard Programming Languages – C Ad 5: Python is not intrinsically fast but IronPython is! . Rasmus Nielsen ([email protected]) Python & IronPython Python vs C/C++/Java/C] Easy to learn, easy to teach No notion of private, public, and sealed, etc. Typing: strong, but dynamic Names have no type Objects have types No "declarations" – just statements Spare syntax, minimal ornamentation: No { } for blocks, just indentation No ( ) for if/while conditions Generally less punctuation – no “;” Everything is “first-class”: object classes, functions, methods, modules . Rasmus Nielsen ([email protected]) Python & IronPython Python extended Look, Ma! Python can do a lot more: Built in support for complex numbers (like Fortran!) Multiple paradigms (OOP, procedural, generic, some functional) Multiple inheritance (like C++) Tuples (like SML) Multiple return values (forget about ref and out) Dynamically typed (like Ruby and JavaScript) Duck typing . Rasmus Nielsen ([email protected]) Python & IronPython Implementations TM CPython (C, Guido van Rossum, 1991) JPython −! Jython (Java, Jim Hugunin, 1997) IronPython (C], Jim Hugunin, 2006) PyPy (Python(!) 2007) . Rasmus Nielsen ([email protected]) Python & IronPython Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages . Rasmus Nielsen ([email protected]) Python & IronPython 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this . Rasmus Nielsen ([email protected]) Python & IronPython Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass . Rasmus Nielsen ([email protected]) Python & IronPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython . Rasmus Nielsen ([email protected]) Python & IronPython Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft . Rasmus Nielsen ([email protected]) Python & IronPython ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! . Rasmus Nielsen ([email protected]) Python & IronPython The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ . Rasmus Nielsen ([email protected]) Python & IronPython IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 . Rasmus Nielsen ([email protected]) Python & IronPython The story of IronPython 2003: “Fact”: the Common Language Runtime sucks regarding dynamic languages Jim Huginin – creator of Jython – sets out to prove this 6 weeks pass Project fails – PyStone benchmark shows IronPython is 1.7 times faster than CPython 2004: Jim feels obligated to continue the work and eventually demonstrates the first version to Microsoft Microsoft hires him right away! ·· v1.0 (2006) ·· v2.0 (2008) ·· v2.6 (2009) ¹ The Dynamic Language Runtime built for IronPython and IronRuby is injected into vNext of the CLR and C] 4.0 IronPython vNext will be released 1-2 months after .NET 4.0 (v2.6 and v3.1 language compatibility) . Rasmus Nielsen ([email protected]) Python & IronPython Why IronPython Reasons that CPython programmers might be interested in IronPython include: Corporate credibility (introducing new technologies can be very difficult in some companies, if .NET is already established then you may need no excuse to start using IronPython) No GlobalInterpreterLock – IronPython has no GIL and multi-threaded code can use multi core processors The .NET framework library is very big. Particularly the user interface library Windows Forms is very good. IronPython is easy to embed in .NET applications as a scripting language Easier to extend than CPython (C] is memory managed and C] types can be used directly in IronPython with no wrapping) Silverlight! (Die, ActionScript, Die!) Source: http://wiki.python.org/moin/IronPython! . Rasmus Nielsen ([email protected]) Python & IronPython The problem with object-oriented languages “The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” Joe Armstrong, principal inventor of Erlang . Rasmus Nielsen ([email protected]) Python & IronPython The world’s smallest C] program – sort of. Listing 1: Hello, World! in C] 1 u s i n g System ; 2 u s i n g System .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages38 Page
-
File Size-