IronPython in Action
Rob Oakes | February 9, 2009 4:46 pm
There is an old adage, often used and much abused, “Give a man a fish and he will eat for a day. Teach a man to fish and he will never want for food.” And while this old saying is extremely tired and very much cliché, it is a surprisingly apt way for me to begin a review of “IronPython in Action,” a programming book by Michael J. Foord and Christian Muirhead.
“IronPython in Action” delves into the use of scripting (or dynamic) languages and how they merge with Microsoft’s enormous .Net platform. For readers of this site, it shouldn’t be any secret that I have been working hard to teach myself Python. And while that particular adventure is better documented elsewhere, “IronPython in Action” has been central to it. Indeed, it has been my primary reference manual and guide.
It’s been nearly six months and it’s far past time to write a review of the guide. But this review is going to be a little bit different than others that you might read. If you are looking for a more traditional summary, you might be better served by Craig Murphy’s exhaustive breakdown. Rather than detail the contents and render an opinion, I would like to first tell a story and then focus on a much narrower question: Is IronPython valuable for people who are new to Python or .Net programming? More to the point, can it be used to teach a novice “how to fish?”
Backgrounds and Purposes
To understand my take on Foord’s book, it is important to understand my background. You see, I am not a computer science person. I am not a programmer. I am first and foremost a research scientist and then an engineer. Most of the time, I am concerned about refining and extending the technology of others; not creating it from nothing. And while I occasionally need to write a bit of code, it usually falls into a realm that most real programmers treat with disdain: scripting. This explains why, for the past five years or so, I have had an ongoing (if rather tempestuous) love affair with a technical computing toolbox called Matlab.
During those years, I have helped The Mathworks Company (creators of Matlab) to line their pockets and strengthen their stranglehold as the de-facto language for technical computing, I have also had a long string of much-wiser computer people tell me that I should consider OpenSource alternatives. (Anyone who is at all familiar with computers should be aware of the OpenSource/Proprietary divide. If you’re not, it is very similar to the Windows/Mac divide; except substitute flame-throwers for flame-bait.) OpenSource certainly has its advantages: it’s free, you can audit the code, there are a huge number of well written extensions, it will never go away, and it has a very enthusiastic community. It also has some severe weaknesses: documentation sucks, there’s no technical support, and it has an overly enthusiastic community. I was particularly hung up on the bit about sucky documentation.
And then, about 18 months ago, something happened that changed my opinion. Instead of trying to apply existing tech to new problems, I and my research group found ourselves looking at some very complex issues that no one had really studied before. It didn’t take long to realize that our existing tool set was completely inadequate. The group desperately needed alternatives to Matlab and I found myself burdened with a rather unpleasant research project. I needed to find and screen said alternatives. This started with Perl, proceeded to Ruby, and eventually ended up at Python.
I quickly decided that I liked what I saw. Python was fast, flexible, and had a very simple (yet elegant) syntax that could be taught to students and technicians familiar with Matlab. There was a large number of extensions available and it was cross platform. There was, however, a major problem: Python lacked bindings for the Insight Toolkit (ITK), an essential framework for people who work with medical imaging data. Cue despair. But … after yet more research, I found an acceptable workaround. While Python might lack bindings, C# does not. Coincidentally, there happened to be a Python implementation which allows for C# code to be used like native Python code: IronPython.
More importantly, however, all of the advantages were retained. IronPython is Python. The syntax still works, many of the extensions will load and run, and (through the use of Mono) IronPython is cross platform. There are additional benefits as well: .Net grants access to an enormous number of very high quality C# libraries. Thus, after careful consideration (lasting about 15 or 20 seconds), I made the decision to move our nascent code from Matlab to Python. There was just one problem, I and essentially everyone else would need to learn Python and .Net from scratch, which might prove a formidable challenge.
Learning IronPython
This is where “IronPython in Action” makes its first appearance. The book was first recommended by a friend familiar with my panic-stricken, “make things up as I go along” style. He said it was well written and would be a good first read for someone with some (but not a whole lot) of computer programming experience. I thanked him for his suggestion and purchased an electronic copy of the work in progress via the Manning Early Access Program (MEAP).
At the time, I had a list of very specific needs:
- Learn Python, its frameworks, syntax, and shortcomings.
- Get a whirlwind introduction to .Net (Mono), its architecture and how IronPython fit into the big scheme of .Net dynamic languages.
“IronPython in Action” fulfilled both, after a fashion, in addition to several more that I didn’t recognize as needs. Of these unrecognized needs, the most important important was facing my own ignorance. You see, IronPython helped me start to fill a few of the holes in my computer science education. Being an engineer and not a programmer, I always considered myself above actually learn how to code. I much preferred a “practical” view of coding best be articulated as, “Make it work! Now!” This “practical” view was most often delivered to an underling, at the top of my voice, prior to a major deadline. And, as might be guessed, it didn’t always lend itself to an elegant, reusable, or even a useful end-product.
Fortunately, Python (by design) encourages all of the above: elegance, use and reuse. More importantly though, Foord and Muirhead stress these concepts from the moment that you open their book. Rather than delve immediately into the gritty of examples, Chapters 1 to 3 insist on providing a comprehensive overview and background to .Net, Python and how the two integrate. To return to the fishing analogy: instead of baiting the hook and getting the reader started immediately, Foord instead opts to describe the tackle and trade tools and how they are used.
This can be quite frustrating to someone who wants to deal with the “practical” world. After all, I want to code, not re-learn how to think! Except … that is exactly what I needed to do. As I read through “IronPython in Action,” I found myself drawn to the many footnotes (29 in the second chapter alone) and references so that I could learn more about a given topic. Instead of tackling syntax, frameworks and shortcomings I found myself reading a great deal about object oriented, procedural, and meta programming. More fatally, instead of focusing on “just making it work,” I was entertaining radical thoughts like “how does it work” and “can it be improved.” Such introspection approaches sacrilegious among “practical” people.
Thus, when the authors do begin to provide examples during Part 2 of the book, the reader is in a much better position to make good use of them. Essential lessons, the equivalent of baiting hooks and making a cast, have already been covered and Foord is able to begin sharing insights into how to successfully “fish.” And there are plenty of said insights covering most major topics of interest: Windows Forms, Web Development, and even Windows Presentation Foundation (WPF). The chapters covering system administration are just a bonus.
An Education
At every point, Foord and Muirhead seem to hold to another old adage, “Rather than ‘teach,’ I would prefer to help you learn.” In doing so, they encourage and empower their readers to explore well beyond the examples and techniques covered within the pages of “IronPython in Action.”
In case it isn’t clear, I heartily recommend that anyone interested in learning Python or .Net purchase this book. It certainly has its idiosyncrasies, but it still manages two roles very successfully: 1) introductory text and 2) reference manual. While novice readers (like myself six months ago) will find tremendous value in reading the book from cover to cover, more experienced hands will find value in skimming individual chapters. As someone who has written technical documentation, I can testify that such a feat is extremely difficult to pull off.
While this style is particularly valuable to the novice, it might not work to the benefit of everyone. More advanced readers might desire to see more extensive/complicated examples or a more thorough overview of both the Python and .Net frameworks. But … I suspect that these individuals will be few, after all, that information is provided by the respective Python Standard Library and Microsoft documentation libraries.
In conclusion, I can only congratulate the authors on this excellent introductory work. While I initially set out with a desire to learn a skill, I instead received an education. In the process, I got excited about programming, Python, and OpenSource. To answer my own question: Can IronPython in Action be used to teach a novice how to “fish?”
Most definitely.
Similar Posts:
- A Pitiful and Pathetic Story
- Backup, Sync and Share – Part 5.1: Windows Vista Backup (Files)
- Inheritance Questions and Answers
- The Collection – A Moment
- I Killed Twitter
Tags: Book Reviews,IronPython in Action,Michael Foord
Categories: Computer, IronPython, Programming
2 Comments »























![Blackwater: The Rise of the World’s Most Powerful Mercenary Army [Revised and Updated]](http://ecx.images-amazon.com/images/I/41ZopVuqGsL._SL160_.jpg)

2 Responses to “IronPython in Action”
For some strange reason, I too have an incomprehensible urge to write in Python. I’m still very much of a beginner but I have been making some very exciting breakthroughs by customizing the source code of the Python based program called “Gramps” to help organize my contacts and basically a journal or life history. The book sounds interesting, although I’m hesitant stepping back into the world of .NET. I keep thinking they are trying to convince me to sell my life savings for a seemingly stress free life of programming.
[...] Rob Oakes Reviews IronPython in Action [...]
Care to comment?