3 ms·
Strong static typing is great. You can cut your runtime bug count by 70-80% easily if you know what you're doing, which provides an enormous increase in product
by pw0ncakes 16y ago
Strong static typing is great. You can cut your runtime bug count by 70-80% easily if you know what you're doing, which provides an enormous increase in productivity. Also, type discipline seems to lead naturally to better architecture. You have to build your data structures and functions from the ground up, which tends to kill a lot of the sloppy thinking and nonexistent architecture that you sometimes see in the dynamically-typed world (although this can't be blamed on the languages, because a lot of users of such languages write great code).
Dynamic typing wins on prototypes and small projects, but for a project of more than 2000 lines, I'd be hard-pressed to see a case where dynamic typing wins.
Of course, I'll add the caveat that good dynamic typing is essential. Most people think dynamic pwns static because they're most familiar with Java and Python, but Java has shitty static typing (you have to declare types, and moreover end up needing to subvert the type system to do anything interesting) whereas ML and Haskell have awesome type systems.
- derefr 16y ago> but for a project of more than 2000 lines, I'd be hard-pressed to see a case where dynamic typing wins Would "the game-world model for a MUD/MOO" be a cheap shot?
- pw0ncakes 16y agoExplain. Large projects are certainly doable in dynamically-typed languages. I just think that static typing becomes a win once you have: * enough code that internal interfaces become important, * enough code that at least 30% of time is spent debugging, and: * more than one programmer on the project by necessity.
- derefr 16y agoIn the world model popular in a http://en.wikipedia.org/wiki/MOO http://en.wikipedia.org/wiki/MOO, almost every object has its own unique set of "verbs" (methods), which each destructively update the world in manifold unpredictable ways. There are no real "classes" of objects, per se, as having more than one of a world object that acts in exactly the same way ruins its "mystique" or "sense of fun"; instead, objects are created first through prototypical inheritance (cloning), and then by defining singleton methods (and adding mix-ins composed thereof), each of which may have originated within any other object. Objects survive mostly by memetic transmission (see an object you like, retain a clone for yourself) rather than some sort of unified architecture.
- btilly 16y agoInteresting. You say that after 2000 lines, people are better off with static typing. But then you make it clear that this is only true if, instead of comparing widely used static and dynamic languages, you compare widely used static languages with best of breed statically typed languages that are not actually in wide use. Where would you say that the trade-off is between dynamic and static if you stick with widely used languages? (From your comments about Java I think you'd choose Python.) Where would you say that the trade-off is between dynamic and static if both are represented by best of breed representatives? Something like Erlang or your favorite Lisp? How does it change things if we take into account the widespread availability of useful libraries for some languages but not others? (The infamous "CPAN argument" for Perl being an extreme example.)
- pw0ncakes 16y agoWhere would you say that the trade-off is between dynamic and static if both are represented by best of breed representatives? Something like Erlang or your favorite Lisp? Lisp is a great language, but I still think static typing wins at a certain point for large projects. Type signatures (which are automatically inferred) provide a certain amount of documentation, and static typing also makes for cleaner and inherently more comprehensible interfaces. When you have multiple programmers, when a lot of time is spent debugging, and when internal APIs become essential, static typing begins to show its strength. People can't just change interfaces willy-nilly and expect everyone else to adapt; the compiler catches this.