Alan Keefer
Posts: 29
Nickname: akeefer
Registered: Feb, 2007
|
|
Re: Programming with "Duh" Typing
|
Posted: Jul 9, 2007 12:25 PM
|
|
I think the point about refactoring and static typing is an important one; changes that are simple in a statically-typed language, like renaming a method, are impossible to do automatically in a dynamic language unless you have something like the Smalltalk browser to do it for you. Perhaps Ruby and Python and Javascript, etc., will have that capability some day, but for now that sort of refactoring remains a huge pain. The fact that those languages lead to smaller codebases definitely mitigates that pain somewhat, but in my (limited) experience with such languages, the end result is that you have a disincentive to keep the code clean: I <i>could</i> rename this method to more accurately reflect its purpose, but it'll take a while to get it right, so it's probably not worth it. In a statically-typed language with good tooling, that's a simple, no-risk operation. I'll believe that Ruby and Python and Javascript can have that level of refactoring support when I actually see the tools.
Dynamic typing makes changes much easier during the initial implementation of a piece of code, when the number of references is small; in that case you probably don't need much in the way of refactoring tools, and the lack of ability to use them is greatly outweighed by the fact that any change you make takes only a few keystrokes and magically (if the duck typing works) flows through the system properly. The number of keystrokes in that case is definitely important, as less code means that I can change things more rapidly.
The combined advantages of type inference and static typing are pretty nice, though; it's not quite the best of both worlds, but I think that on balance it's better than either just static typing or just dynamic typing. Combine it with some manner of extensible type system to make it that much more dynamic and it's hard to beat. It reduces the amount of code you write and you get something kind of like duck typing in a lot of cases, while also maintaining the tool-ability, refactor-ability, and error-checking of static types.
|
|