Book Review: IronPython in Action

I guess that to many people IronPython, an implementation of the Python programming language that runs on Microsoft’s .NET platform, is little more than a curiosity. For them, a glance at the preface and foreword to this new Manning title may be enough to convince them that it is at least interesting. In the foreword, IronPython creator Jim Hugunin describes how he first worked on Python for .NET as an exercise to prove “why the CLR is a terrible platform for dynamic languages”:

The plan was turned upside down when the prototypes turned out to run very well – generally quite a bit faster than the standard C-based Python implementations.

Next is a preface from the authors, Michael Foord and Christian Muirhead, about how IronPython came to be used in an innovative programmable, testable spreadsheet called Resolver One:

Resolver One is in use in financial institutions in London, New York and Paris, and consists of 40,000 lines of IronPython code with a further 150,000 in the test framework. Resolver One has been tuned for performance several times, and this has always meant fine tuning our algorithms in Python. It hasn’t (yet) required even parts of Resolver One to be rewritten in C#.

Why is Python used in Resolver One?

As a dynamic language, Python was orders of magnitude easier to test then the languages they had used previously.

If that piques your interest, you may find the book itself worth reading. It is aimed at Python programmers who do not know .NET, and .NET programmers who do not know Python, rather than at existing IronPython developers. The authors run through the basics of Python and its .NET integration, so that by the end of Part 1 you could write a simple Windows Forms application. Part 2 is on core development techniques and covers duck typing, model-view-controller basics, handling XML, unit and functional testing, and metaprogramming – this is where you generate and execute code at runtime.

The third part of the book covers .NET integration, and how to use IronPython with WPF (Windows Presentation Foundation), PowerShell, ASP.NET, ADO.NET (database access) , web services, and in Silverlight. Finally, Part 4 shows how to extend IronPython with libraries written in C# or VB.NET, how to use Python objects in C# or VB, and how to embed the IronPython engine into your own application.

It’s a well-written book and fulfils its purpose nicely. I like the way the book is honest about areas where IronPython is more verbose or awkward than C# or VB.NETAs someone who knows .NET well, but Python little, I could have done without all the introductory .NET explanations, but I understand why they are there. I particularly liked part two, on core programming techniques, which is a thought-provoking read for any developer with an interest in dynamic languages.

According to the IronPython site, you can get 35% off by ordering from the Manning site with the code codeplex35.

It is also available on Amazon.com:

and Amazon.co.uk: