January 20, 2009
Are Dynamic Languages The New Black (Again)?I must say, I'm not so big on accepting things at face value.
And in my line of work, there's a whole bunch of "facts" and "accepted truths" that are anything but. Much of our understanding about why things tend to work (or don't work) is arm waving at best, and totally non-existent at worst.
Take the current perceived trend towards dynamically-typed scripting languages like Ruby and Groovy. Proponents of such languages cite the relative flexibility of dynamic typing compared to statically-typed languages like Java and C++. Type safety, they argue, can be achieved through unit testing. Write a test for a.b(c), and if a or c are of the wrong type in that scenario, the test will fail when the interpreter gets around to checking what's in those slots.
True enough: provided your unit tests provide adequate assurance. And, let's be honest now, 95% of teams' tests don't. Not even close.
More important to me, though, is this underlying assumption that we should make the extra effort because it's worth it to allow us to work in dynamically-typed languages. Why so, I wonder? I've worked in a selection of such languages, practicing TDD very fastidiously, and found no net benefits.
And now I see .NET folks relying more and more on var declarations, because - well, apparantly because they can and the books and blogs say that they should. But I'm not sold on the reasons. Greater run-time substitutability? Perhaps. But why not just make all methods virtual by default unless otherwise specified? Why not make it so that any class can be extended and any method overridden, if that's what we apparantly crave? For sure enough, if we call a.b() and a doesn't have a b() when it comes to execution time, then what have we really gained?
I put it to you that the current fashion for dynamic languages is excatly that - a fashion. And many people are using them because they've seen other people using them, and they want to be in with the in crowd.
I'm not saying dynamic languages are bad, or that we shouldn't use them. I'm just questioning the received wisdom that they are somehow better than statically-typed languages. In the absence of any hard evidence to support that, I'm forced to remain agnostic.
UPDATE: Reading people's email and blog responses has highlighted another issue with dynamic languages, which is that we don't all seem to agree on whast we really mean by "dynamic".
Posted 11 years, 9 months ago on January 20, 2009