Static vs. Dynamic Typing
Sunday, November 30th, 2003To anyone interested in the nuts and bolts of things like programming languages and compilers, I highly recommend the “What the heck is…” series of articles that Dan Sugalski, one of the architects of Parrot (the VM at the core of Perl 6), has been penning for his weblog.
Dan is one of those rare supergeeks who actually posesses the ability to write clearly and engagingly about his work, and as far as I’m concerned, his weblog is a great educational resource. He also seems to be refreshingly free of a lot of the dogma that tends to characterize discussions about programming languages, as he demonstrates in today’s even-handed discussion of the ever-popular static versus dynamic typing debate:
Which is the right answer? Well… it depends, of course. Depends on the people involved, as the differing styles of typing appeal to different people. It also depends on the problem, since some problems require more stricture than others. (I, for one, want the code running a plane I’m in to have all the checks run on it as possible). And it depends on the performance requirements you have, since the more statically typed a language is the faster the code can be. (Not necessarily will be, of course, but the less uncertainty the optimizer has the more it can optimize). There really isn’t One Right Answer. That’d be too easy.
![]()
I couldn’t agree more. Dynamically typed languages like Objective-C have attractive advantages for certain kinds of applications (they allow greater flexibility in the development process and facilitate elegant designs like Cocoa’s “responder chain”), but also tend to have liabilities in terms of performance overhead and the increased possibility of runtime error. The important thing is simply to consider the application and choose the right tool for the job.
