Tuesday, January 29, 2008

Can Dynamic Languages Scale?

Currently, there is one of these "dynamic vs. statically typed languages"-discussion going on at theserverside.
I found especially the discussion regarding "IDE support" funny, because both sides seem not to have an idea of how it "feels" to work in the other environment. I don't have "real project" experience using dynamically typed languages either, but have tried many of them to do smaller tasks.

For me the "type safety" of statically typed languages isn't important. What is important is the IDE's knowledge of the static type information and what can be done with that. There is much more than just 'refactoring' or 'compiler checks', which are both very useful of course. Btw. refactoring in Eclipse's JDT or IntelliJ's IDE is far more sophisticated than what the old smalltalk 'Refactoring Browser' can do. And this has to do with the availability of static type information.
What about all the cool Navigation features, type hierarchy view, call hierarchy, etc. ? With static information in place one can view the source base from different angles using different levels of abstraction. Of course some of these things can be done without static type information as well, but not near to what you'll find in the IDEs I mentioned above.

Most of the hype about dynamically typed languages like ruby, python or groovy are because the existing statically typed mainstream languages are just very verbose and lack a number of important features (e.g. closures). Have a look at languages like Scala or even C# 3.0, they are statically typed AND expressive at the same type. Unfortunately Scala doesn't have tooling comparable to JDT so far.

One important thing left to dynamically typed languages is meta-programming, i.e. introducing new types and features at runtime. This is indeed very useful sometimes.
In statically typed languages this is most often solved using code generation, but IMHO there is also a need for using reflection in a briefer way.
Ultimately one could introduce some kind of compiler-escape syntax into a statically typed language so we can write:


instead of the usual reflection code :


Of course the language must not use static type information (like casts) at runtime any more. For me static typing should just be an IDE (and compiler) thing. The runtime shouldn't use any static type information.