Wednesday, August 08, 2007 4:24 AM
by
dodyg
Havana: Hybrid Programming
I have been programming exclusively in C# 3.0 and IronPython daily in the past 2 months (and partially 4 months before that) for Havana and these are my impressions on them so far.
- var keyword in C# 3.0 is actually a big deal. Yes, you might scoff at the idea of saving a couple of keystrokes matters little but I found reading C# code with var attribute in front of it much easier than without. This is no doubt influenced by Python programming where you don't have to declare a type in front of a variable.
- I used to slam the automatic property declaration functionality in C# 3.0 and even made fun of it a couple of months ago. Well, I'm sorry I did that. I found these automatic properties a pleasure to work with in declaring various Data Transfer classes.
- LINQ for XML is a big deal. I hate XML less now. I didn't find myself using LINQ for object that much but they have been invaluable in mixing and matching data structures.
- I find Object Initializer very useful in making my code easier to read. I use array a lot more often than before.
- I barely use anonymous types. I don't find them that useful mainly because they are locally scoped to methods only.
- Lambda expressions/statements is like Cocaine. Very addictive. () => return new SomeClass(); is very neat :)
- I haven't touched Expression Trees.
- I develop features faster in Python than C# 3.0 but I dread doing refactoring in Python due to the lack of support in Visual Studio for the language.
- Python is a great ASP.Net code behind language. I have been using pattern such as
res, message = Validate()
in many parts of my code. And the ability to manipulate sequences such as "content[:300]" is a heaven sent.Once you get used to using Request.MyId in if (Request.MyId is not None):, you can't go back to the clunky way of using Request.QueryString["MyId"]. It reads better as well.
- Try this : def btnSave_Click(sender, e):. Less typing by almost half compared to C# 3.0.
- IronPython.Hosting is a big deal. The ability to create delegates and objects out of a bunch of string is really really powerful.
- In Python, it is much faster to do stubbing for your code. You can write non existence methods and it won't generate error until you perform certain action that actually executes the method.
- Extension Methods: Love it, love it, love it. It allows scope based programming. I have been using it extensively especially in the object/orm assignment. I have been able to keep my objects clean of the fill in/fill out methods until I need them in persistence realm.
- ASP.Net low level infrastructure is well designed.
In Summary :
- Less Code Matters A Lot.
- C# 3.0 really shines for back end development. It doesn't add much value in the current ASPX Page structure code behind.
- IronPython really shines for CodeBehind code or anything related to UI programming. I can't fathom using it for back end programing due to the lack of refactoring support.
- Using both C# 3.0 and IronPython in the same project is a joy.