IronPython in Action reviewed
Posted by Jason Baker on June 28, 2009
IronPython in Action by Michael Foord is a somewhat interesting book in that it isn’t really isn’t about IronPython. It’s a book about programming in .Net using Python. Although some will accuse me of being overly pedantic, there is a subtle difference.
After all, IronPython is just a piece of software. Anytime you have a bridge between two languages and/or programming environments, there are always some “devil’s in the details” type issues that come up. These are questions like:
- Are IronPython strings the same thing as .net strings?
- Can I use ASP.NET with IronPython?
- Can you call any .Net code from IronPython?
Who it’s for
If you’re a new programmer, IronPython in action probably isn’t the book for you. Although it does have an introduction to programming in Python, it’s very brief.
On the other hand, if you’re an experienced programmer who already knows what variables are and why classes are useful, you’ll likely find IronPython in Action a pretty good primer. Although this book does have an introduction to both Python and .Net, I think you’d get the most benefit if you have experience with one of those technologies.
IronPython in Action in Action
IronPython in action covers three main areas: Python, .Net, and Usage of IronPython. I’d like to cover these sections individually.
As mentioned, the book does include a brief tutorial on Python. If you’re a total newbie to Python, you may want to keep the official Python tutorial nearby in case it goes too fast for you.
That said, the section on Python is fairly readable. It even has diagrams if you’re the kind of person who learns visually:
…although I’m pretty sure I could have figured out what a set of parenthesis and colon is on my own, thank you very much.
I’ve always thought that there were two layers to Python: the “normal” stuff and the black magic. Foord doesn’t just stick to the easy stuff either. The deepest depths of the Python language are covered all the way up to metaclasses, the arch-typical example of Python voodoo. This isn’t what makes this part of the book shine though. Any idiot can learn how to use a metaclass by spending some time with the Python docs. No, the place where this book really shines is in how it teaches these concepts. The line between Python newbie and Python wizard is in knowing when to use the magical parts, and Foord does an excellent job of giving real world examples of these.
I also found it interesting to that the book mentions some popular third party Python libraries and tools. For instance, the section on testing includes a summary of some test-runners such as nose to help simplify running tests. As anyone will tell you, Python’s greatest advantage is its huge standard library and its even bigger set of third-party libraries.
In all, this isn’t just a good way to learn how to use IronPython. This is a good introduction to the Python language itself.
After that, IronPython in action delves into how .Net works and how IronPython works with it. Just as with the Python introduction, you won’t come out of this a .Net expert if you weren’t before. However, it’s helpful if you’re not familiar with what an assembly is or want to know how the heck you’d use a generic with a language as dynamic as Python. As it turns out, IronPython works pretty well with .Net in all but a few cases.
The book leaves no stone unturned as far as the .Net runtime is concerned. It goes from the basics like using .Net classes all the way up to the dirty stuff like using P/Invoke and creating dynamic objects in C#/VB.NET. In short, I can’t think of many features of the runtime itself that this book doesn’t cover.
I was a bit disappointed that third-party .Net tools didn’t get as much coverage as Python’s did. For instance, ADO.NET simply isn’t enough to get a full picture of how to use databases with .Net. Since most of the Python ORMs may not have very good support as they rely on C extensions, why not cover an ORM like NHibernate or Subsonic? Or why not show how to write tests using NUnit in addition to Python’s unittest framework? Or why not cover interoperability with other .Net languages like F# or Boo?
Arguably the best part of this book is in the sections “Core Development Techniques” and “IronPython and advanced .Net”. This is where you get into the real meat of using IronPython.
IronPython in Action is a very practical book. It teaches you not only the theory of using IronPython, but the practice as well. It teaches you how to use IronPython to do test-driven development, how to read in XML files much more easily than in Python or C#, it even goes into detail on some of the hottest .Net technologies like WPF and WMI. Virtually any type of programmer will get a brief introduction to doing the things they want to do in IronPython.
One area that I’d like to see covered more is GTK#. It’s not quite as cool as WPF, but it’s cross-platform and much better than WinForms. My experience has been that PyGTK+ can be a major pain to install on some platforms, so it would be helpful to have an introduction to the .Net equivalent.
In summary, if you’re a developer wanting to work with Windows technologies using Python there’s no question: go and buy IronPython in Action. Right now. If you’re wanting to develop IronPython applications for various platforms or don’t want to tie yourself to just Microsoft technology… still go and buy IronPython in Action. There are still some holes that can be filled, but all in all, this is a pretty solid book.