Byon January 6, 2009 4:58 PM
Perhaps it’s because I cut my teeth on C, which despite appearances is really a dynamically typed language, since type names do little more than tell the compiler how many bytes it should be addressing at that moment in time, or maybe it’s the fact that much of my programming time is spent on the web, where really, everything is a string. I’m not sure I buy that one, though, most of my programming in College was centered around binary data, and I used to hack proprietary file formats for fun.
Maybe I’m just getting lazier, but constantly having to manage types is really getting annoying. This is a little worse today than it’s been because I’m finally getting back into Android programming, and I’d forgotten how much manual type coercion Java really forces you to do that C# handles on the backend for you. If it’s not already obvious, I’m definitely in favor of Dynamic type systems. The just make for easier code to write, and easier code to read.
Now, while I definitely prefer dynamic typing, there is the valid performance argument. Dynamic typing is slower. This is a fact. However, for most uses these days, it isn’t noticably slower. Computers are fast enough today that the overhead involved is negligible for almost all applications, but there is one place where static typing is still generally preferred. Mobile Computing (primarily phones) require static typing, not so much because of the speed of the application execution, but because the battery life would be negatively impacted by the constant messing around with determining (or modifying) types.
However, that doesn’t mean that I can’t program as if the types were more dynamic. C#, particularly in later versions, has implemented a ton of compiler hacks which make C# seem more dynamic. The ‘var’ keyword, inline property setting and dictionary construction, plus quite a few more things, all making the code easier to write, while keeping the language static. I’d be a lot happier with Google’s choice of Java for Android if Java would implement even a small number of these more ‘dynamic’ features. Perhaps I should just put together a C# compiler that spits out Davlik Bytecode (I wonder how modular the Mono compiler source is?).
Well used, dynamic typing can lead to much cleaner code, much faster. I’m very glad to see the trend in Software Engineering toward dynamism, even if it frankly could come much faster than it is.