Sunday, May 03, 2009

Book — IronPython in Action by Foord & Muirhead

IronPython is an important language.

Back in 2000 at the Microsoft PDC, where the .net platform was unveiled after much hype, we were given a vision of the Common Language Runtime as a truly polyglot platform, with 15-20 languages having been fed into the design, tantalizing code snippets shown -- and even previews of ActiveState's real-soon-now Python.NET and Perl.NET implementations.

And then for five years, .net programming meant no more nor less than C# (or VB.Net if you swung that way), with the two languages adopted for the platform from the wider world being at best niche -- J# a known dead end, and C++ for .net never really recovering from the horrible extensions used in the first attempt at the job.

And then, in 2005, it was steam-engine time : the first inklings of an ML dialect, labelled F#, for .net from Microsoft Research, and IronPython, a project initially undertaken to show why Python on .net couldn't be done -- a meme whose genesis I strongly suspect lies in the failure of that early ActiveState effort. While, however, F# still remains a CTP release (even at a 1.9.x release number) to this day, the IronPython 1.0 production release (Python 2.4 compatibility) was the best birthday present I never realised I'd received in 2006. Yet, until very recently, whereas F# was supported by several books, all published even before the CTP announcement, even as a production release, IronPython languished in the English language press.

IronPython in Action now fills that surprising gap.

The task the authors set themselves is an heroic one -- to teach Python to .net programmers, and .net to Python programmers, and, just in case that was not enough, several of the more outré parts of .net, and good programming practices, for just about everybody as well. What makes this a great book is that, in the course of about 450 pages, with copious external citations, they actually succeed.

Part of the secret of the success is that this (like Programming in Scala) is not a beginner's book and assumes the reader has a degree of familiarity with basic programming concepts -- for example, the Python if, for and while statements are covered together in just over a page, with the link collection in Appendix C there in case a more at length treatment is required -- so freeing space for more advanced material to be covered.

The scope of the material covered came as a most pleasant surprise -- when I pre-ordered the book, it was as a gesture of support, because the language deserved a presence in print (after all, I'd been programming since whenever, using .net since it hit 1.0, and IronPython for a couple of years, so not much of it should be exactly new...); when it finally arrived and I could read it, I found there were significant things I could learn from it, new insights and just better ways to achieve some things already did.

In particular, the chapter on testing is pretty much worth the admission price all by itself, simply for the worked example of how to solve that perennial problem -- performing automated testing of a .net GUI application (as opposed to just testing the backing libraries).

You don't even need to use IronPython as your .net language of choice to benefit from much of the third section of the book, Advanced .NET. This not only covers parts of the framework too often neglected in C# texts (like the extremely useful, if unsexy, System.Management namespace), but also provides a more measured introduction to the sexier new technologies (WPF and Silverlight) than the books dedicated to those technologies that I have read. Where it is specific to IronPython, this section also serves to emphasise the importance of the language within the larger world of .net, with the ASP.Net extensions for dynamic languages, and the inclusion of the dynamic language extensions (the DLR) within Silverlight.

And if you don't yet use IronPython (or the less mature IronRuby), there's really only one thing that this book neglects to point out about the language -- but it's one that might finally change your mind. Although it's now distributed as an .msi installer, once unpacked, the required assemblies can still be simply XCOPY installed to run on any machine with the .net 2.0 or later framework already in place, giving you a .net-aware scripting language anywhere you have .net already.


Disclaimers: Yes, I do get a shout-out in the book for one of my earlier postings in this blog. And while I would have written a review anyway, for the same reason I bought the book sight unseen, I have since been suggested to the guys at Manning Publications as a potential reviewer by the authors. So, here is the review you were looking for.

This review is released under the WTFPL.

Post a Comment