Saturday, November 8, 2008

The Variant strikes back

Anders Hejlsberg, lead-architect of C# announced at the PDC 2008 that C# 4.0 will be enhanced towards a dynamic language. With the keyword "dynamic" you can declare a variable as a datatype that will be bound at runtime rather than compile time.
The background is, that it will make the use of COM components much more convient. Today you link your code against the exact version. If the version of your component is not installed on the remote computer your code will fail, even if the interface the installed component has not changed.
Reflection is in its usage for emergencies only and not suited for complex interfaces. Your code will become a huge mess if you try to handle complex objects.

So this is a HUGE break with current C# dogmas..

But wait a minute! Don't all of you, who know what's behind the letters "VB" feel strangely remembered? Something we thought we had burried a long time ago?

The VARIANT strikes back!

And to be honest, coming down the C, C++ path I feared and hated it, whenever sub-average VB programmer colleagues started using it in their code. The Variant or Dynamic liberates developers from spending a minimal time on thinking before start coding. They simply declare some global "Variants" and use them to store whatever comes along. Absolutely impossible to tell whats the content of the variable when you read the code. The absolut horror of everyone who has to maintain or debug this kind of code.

I clearly see the advantages of runtime binding, but I see the immense risks the same time.

Maybe you should pass some sort of qualification exam to get this type enabled.

"Anders Hejlsberg, Chef-Architekt der .Net-Programmiersprache C#, hat im Rahmen der Microsoft Professional Developer Conference (PDC) in Los Angeles neue Sprachfunktionen für C# 4.0 und die darauf folgende Version erstmals vorgestellt.
Die Hauptneuerung in C# 4.0 ist die Erweiterung in Richtung dynamischer Sprachen. Mit dem Schlüsselwort dynamic können C#-Entwickler in Zukunft eine Variable so deklarieren, dass die Bindung erst zur Laufzeit stattfindet." (Heise.de)