IronPython, C# 4.0 & Me

IronPython In Action

This week I had picked up a copy of IronPython in Action.
Lately I have been writing or mentioning at least how I am pretty impressed about the .NET framework/Visual Studio/C#. I found things to be extremely fluid, logical and pretty much straight forward using C# (with the nice room to get complicated if you’d like).

Python though has remained outside my scope of knowledge for quite a while. I have friends who swear by it and I’ve been always been meaning to learn properly a scripting language. I had briefly touched Python in one my CS courses, however it was using Jython which is an implementation of Python written in Java. To be honest, at the time of learning Jython (pretty much Python) scared me a little.

Dynamic programming languages scare me a little
The ability to cast on the fly scares me.
The ability to create member variables on the fly scares me.

Data attributes correspond to “instance variables” in Smalltalk, and to “data members” in C++. Data attributes need not be declared; like local variables, they spring into existence when they are first assigned to. For example, if x is the instance of MyClass created above, the following piece of code will print the value 16, without leaving a trace

I can see the benfit of being able to do it and the marvels that it can accomplish; but it seems it might cause a nightmare for debugging someone else’s code. Although I’ve never tried so hopefully I’m wrong.
I think buying this book is a good start. It seems as if Dynamic programming requires rethinking problems in a different way; similar to trying to solve a problem parellelly rather than sequentially.

The real reasons what attracted me to try and learn IronPython is the development cycle to create a sample WinForms application looks to be much shorter and much of it can afterwards be easily ported to straight C#. Finally a good CS professor once told the class that:

All programmers should know at least one scripting language

C# 4.0

Seems as if learning Dynamic programming design pattern and principiles could be useful especially with the upcomming release of C# 4.0 I was recently going over the WhitePaper for C#4.0 and they are heavily entering the forray of dynamic programming it seems especially.

C# 4.0 introduces a new static type called dynamic. When you have an object of type dynamic you can “do things to it” that are resolved only at runtime:

The C# compiler allows you to call a method with any name and any arguments on d because it is of type dynamic. At runtime the actual object that d refers to will be examined to determine what it means to “call M with an int” on it.
Other things which will allow for code refactoring seem to be introduced in C# 4.0 as well such as optional and named arguments. I can finally stop from creating so may overloaded methods.

Anyways in the mean time I will be playing with IronPython. There is something sexy about interacting with a GUI through an interactive interpreter.

One Reply to “IronPython, C# 4.0 & Me”

Leave a Reply

Your email address will not be published. Required fields are marked *