Tuesday, June 30, 2009

IronPython in Action

image Writing a book about IronPython presents a dilemma, do you write a book introducing Python to .NET developers, or do you write a book introducing .NET to Python developers? Striking the right balance between the two is always going to be difficult, but Michael Foord and Christian Muirhead have made a very compelling attempt. Of course I can’t speak for the Python hacker coming to the world of .NET for the first time, but for a .NET guy like me, the book is an excellent introduction to Python and how IronPython works with the rest of the .NET ecosystem.

It’s a very well written and crafted book, with an easy to read conversational style. I find many programming books quite hard work, but this one was a pleasure.

The compromise for me was a rather too high level introduction to Python itself, I would have preferred a deeper introduction to the details of Python and its standard libraries. But then I guess I could always go and buy a Python book, or check out the prodigious online resources for a more in-depth view. I’m not particularly interested in Winforms programming, so I didn’t really get much out of those parts of the book, but I guess the detail is understandable when you know that the authors day job is programming a large winforms system, Resolver One. Chapter 8 on metaprogramming and protocols was very interesting for a dynamic newbe like me, and chapter 15, on embedding the IronPython engine, also sparked off quite a few ideas.

I disagree with Craig Murphy’s comment on the back cover, “… and if you are new to programming, it’s for you too.” Michael and Christian go too deep too fast for a complete beginner. You would really need to have some background in either .NET or Python to get the most out of this book.

So am I excited about IronPython? A bit. I think I need to actually try some serious programming with it. For me its two obvious applications are as an embedded scripting language and for those tasks that don’t justify a fully compiled .NET application, such as automated deployments. I’m sure that you could be very successful building large applications with it, as indeed the authors have, but I don’t feel immediately compelled to drop C#.

I’m certainly not as excited about IronPython and the DLR as I am about functional languages such as F#. Functional programming really is a new paradigm. If you told me we would all be writing our applications with dynamic languages in ten years time, I’d be sceptical. But with functional languages, I’d be inclined to agree. Maybe we will see the emergence of a more polyglot programming ecosystem? In that world there’s certainly a place for IronPython.


Richard OD said...

"Functional programming really is a new paradigm.". ML was created in the 1970s, Haskell in the 80s- am I missing something?

Mike Hadlow said...

Richard OD,
And LISP was created in the 50's.

Of course it's not a new paradigm for the programming world in general, but it is a new paradigm for .NET.

Richard OD said...

I see- just that one sentence was confusing, I didn't mean to sound critical (which I think it sounds having re-read it). I certainly think F# will be worth learning. I don't think I'd bother with IronPython though.

Roll on VS.NET 2010!

preet sangha said...

I need to do a post about how we've used iron python in our app. The power of the DLR (and older scripting runtime) together is amazing. In a nutshell declarative code (dlr) and declarative markup (xaml) are a match made in heaven. I remember you messing about with Haskell I think or was it F# a few years ago adn I've read some of your posts on the subject. Yes I agree that the functional paradigm is compelling but the power of the DLR is completely orthogonal to this and we shouldn't be doing apples to oranges type comparisons.

Mike Hadlow said...


That does sound interesting. Do you have any resources you can point to?

preet sangha said...

DLR as declarative code? I'll see what I can dig up. But not seen anything except what we've done here.

I'll try put a sample together.

preet sangha said...

Ok while building a minimal sample I found this. Not quite what I had in mind (as it uses the dlr code in side the xaml) but serves the point.

Mike Hadlow said...

Thanks Preet, I look forward to checking it out.