IronPython Programming Language

Python for the .NET and Mono Frameworks

IronPython is an implementation of Python, a popular high level object-oriented dynamically typed programming language. It is written in C#, built on the Dynamic Language Runtime and runs on the Microsoft .NET framework and Mono.


Python

Python is a popular programming language, originally created by Guido Van Rossum in 1991. It is a high level, open source, object-oriented and dynamically typed programming language.

Notable features of Python are that block structure is delimited using indentation (although the language is not otherwise whitespace sensitive) and that all variables are references. Garbage collection is by reference counting (with a generational cycle garbage collector) and Python is byte-code compiled.

The reference implementation is often referred to as CPython, because the Python VM and several of the core libraries are written in C. IronPython is an implementation of the Python language, along with several of the core libraries in C# - the defacto programming language of the Microsoft .NET framework and Mono.

IronPython

The IronPython project was started by Jim Hugunin, who also created Jython - an implementation of Python on the JVM. After demoing IronPython to microsoft they hired him to work on the Common Language Runtime team, partly with the aim of making the CLR a better platform for dynamic languages.

IronPython was released under an Open Source license, which was approved by the OSI with the name "Microsoft Public License". It is usually abbreviated to MS-Pl.

After completing IronPython 1, a dynamic language hosting environment and shared type system was abstracted out of IronPython. This was named the Dynamic Language Runtime, and IronPython 2 was started built on top of the DLR. Microsoft has also created two other languages that run on the DLR, Managed JScript (an ECMA 3 compliant implementation of Javascript) and IronRuby.

The current stable version of IronPython is 2.0, which targets Python 2.5. The msi installer includes the Python standard library.

Silverlight

The Dynamic Language Runtime, and the languages that run on top of it, runs on Silverlight 2. Silverlight is a cross browser (Safari, IE & Firefox), cross platform (Apple Mac & Windows) browser plugin. It ships a cut down version of the .NET framework (called the 'Core-CLR'), allowing it to be programmed in C#, VB.NET or any of the DLR languages. Silverlight has a user-interface system based on Windows Presentation Foundation (WPF), that can be used from code or XAML (eXtensible Application Markup Language).

The IronPython binary distribution includes Silverlight binaries, but there is a separate Silverlight Dynamic Languages SDK available.

As Silverlight exposes the browser DOM, and allows communication between Javascript and code running in Silverlight, the browser is natively scriptable with Python through Silverlight. Silverlight also has APIs for working with XML, threading, network access including sockets and storage in the browser cache. It has similar cross-domain access policies to Flash.

Support for Silverlight on Linux will be provided through the Mono Moonlight project. Microsoft are supporting Moonlight (which will initially run on Firefox on Linux but will eventually run on all Mono supported platforms and multiple browsers) by providing media codecs, tests and open sourcing some of the Silverlight controls.

Advantages of IronPython

For .NET Programmers

  • All the advantages of a dynamically typed language, plus the particular language features of Python
  • Python is a multi-paradigm language - interactive, procedural, functional, object-oriented and metaprogramming
  • The interactive interpreter is a great tool for exploring assemblies and classes with live objects
  • Python is a great language for the rapid development of prototypes, and it is particularly amenable to automated testing
  • IronPython is a ready made scripting language for embedding into .NET applications
  • It is particularly suited to creating DSLs that allow business logic to be stored as text and modified without recompiling the application

For Python Programmers

  • Access to .NET libraries - including the Windows Forms and WPF UI toolkits
  • IronPython is dramatically easier to extend with C# than CPython is with C
  • IronPython (based on .NET) may be an easier sell politically (in a corporate IT environment) than CPython
  • Script the browser with Silverlight
  • Create binary distributions of applications, or applications with multiple Python engines (difficult with CPython)
  • Applications can execute code inside AppDomains with restricted privileges (again - hard in CPython)
  • .NET has a better threading model than CPython (no Global Interpreter Lock and the ability to abort threads) - so you can create threaded applications that use multiple CPU cores


Topics still to cover:

  • FePy - IronPython Community Edition
  • Python standard library compatibility
  • Resolver One
  • IronPythonStudio and Visual Studio integration
  • Other projects - Robotics Studio, ASP.NET Futures, Volta
  • Code examples of Python
  • IronPython .NET integration through the clr module
  • Features of IronPython like static compilation and COM interop
  • Comparison with Python.NET

Comments

Michael Foord
Michael Foord
Software Engineer at Comsulting.de
Northampton UK
Article rating:
Your rating:

Categories

Based on community consensus.

Activity for this knol

This week:

10pageviews

Totals:

1120pageviews
1comments