Rob Oakes: Learning IronPython

Rob Oakes has set about learning Python through IronPython, and has written a series of articles that both document his progress and serve as a tutorial for others following in his footsteps.

He starts with a confession and a manifesto:
There are certain times for confessions, and now seems like such a time so … here goes: My name is Rob, and I’m an addict. I am addicted to Matlab. If I didn’t have Matlab, my productivity would go to near-zero. For this reason, like any good junkie, I tolerate its expensive fees, obnoxious quirks and serious limitations. That is, until recently.

Some recent events, however, have forced me to start looking for alternatives. [...] I have made a serious decision: I am going to learn Python!
And why Python?
  1. Like Matlab, it is a dynamic (or scripting) language.
  2. Like Matlab, it has an enormous number of existing libraries and functions available. Indeed, after a bit of surface scratching, I’ve come to the conclusion that it might have even more libraries and functions available than Matlab does. Put differently: Python comes with batteries included.
  3. Python has some seriously beautiful syntax.
Even better: "I have started reading the book. Chapters 1 to 3 of IronPython in Action are great. The first three chapters start with a fantastic summary of Python and .Net".

His second article introduces the projects he will work on to learn IronPython, including a Windows Podcast aggregator based on the Windows Presentation Foundation (WPF) GUI framework.
Part three is more code focused and is an introduction to using WPF from IronPython, including the basic user interface components like, loading XAML at runtime, and using doing work in a background thread with the BackGroundWorker class (updating a progress bar as it goes). He made good use of the IronPython in Action examples and the IronPython Cookbook, which is nice to see.
Part 4 is about .NET interoperation, extending IronPython and creating a download manager using the Background Intelligent Transfer Service (BITS).
Part 5 puts what he has learned so far into practise, in the form of a rudimentary download manager. Again, this entry has useful example WPF code.
Part 6 makes the download manager more functional, with more example IronPython and XAML. The download manager is starting to look a bit more impressive.
Part 7 summarises what Rob has learned on his journey:
His major points are:
  • Set goals and measure progress
  • Follow schedules while maintaining flexibility
  • Work on something real
  • Try things out
  • Limit the number of dependencies
  • Find high quality reference and documentation
Under the "Try things out" heading, he makes this note about the Python interactive interpreter (REPL):
Unlike compiled languages, Python and other scripting languages ship with an interactive interpreter that begs to be used. When trying out the various .Net classes, I tried to apply a piece advice found in IronPython in Action.

For those new to dynamic languages, the interactive interpreter will … be a pleasant surprise. Far from being a toy, the interactive interpreter is a fantastic tool for experimenting with classes and objects at the console. You can instantiate and explore … classes live, using introspection and the built-in ‘dir’ and ‘help’ commands to see what methods and attributes are available to you. As well as experimenting with objects, you can also try out language features to see how they work … (IronPython in Action, Chapter 1).

I found the interpreter to be a fundamental part of my experimentation. As you can see from the screen shot at left, the interpreter became one of my most used programs. it even passed Microsoft Word, which is the first program I open after turning on my computer.

I often found myself transcribing interpreter commands into my code, once I had figured out how to accomplish a particularly difficult set of manipulations. In many ways, the interpreter became my de-facto composition board and I was able to avoid the write-compile-run loop equivalent which often sucks up my time when working in other languages.
These articles were only the first part, the download manager, of his podcast aggregator project. Before moving onto the next part (the 'library') he lists some of the tutorials and resources he found useful whilst learning to use WPF from IronPython:
I'm sure we'll see more good things from Rob as he continues his adventures.

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

IronPython Tools for Visual Studio CTP3

Further Adventures of the Debugger