3 ms·
Actually, any comparison between dynamic and static typing is prone to bias, only because such comparisons are focusing on features -- whereas what's important
by bad_user 16y ago
Actually, any comparison between dynamic and static typing is prone to bias, only because such comparisons are focusing on features -- whereas what's important really is style / use-cases.
And all the articles about Scala are missing one important detail -- structural typing and type inference are not a replacement for dynamic typing and all evidence to the contrary I've seen are extremely shallow.
Truth of the matter is the choice between static and dynamic comes down to personal style and individual use-cases for which one or the other is better.
- shasta 16y agoStructural typing and type inference aren't a drop in replacement for dynamic typing, but they cover 80% of the use-cases and the typically the other 20% of cases aren't that painful to encode in a static language. I'm curious which idioms from your favorite dynamic language you find the most painful to adapt to a static language. I think that the path forward for programming will see a convergence between static and dynamic typing, but the amount of static analysis that programmers do will only increase. Certain dynamic practices such as name binding at runtime will fall out of favor, because that practice hampers static analysis. On the other hand, static type systems in use will probably become more flexible, simultaneously increasing the things that they let you automatically track while decreasing the things that the force you to track. Time will tell, I suppose.
- bad_user 16y agothey cover 80% of the use-cases No they don't, it's actually the other way around -- try recreating Rails in Scala. For that matter, give me an ORM written in Scala that's both (a) stable and consistent + (b) usable without me having to bash my head against the keyboard. The reason why you cannot recreate a Rails clone is because Rails works basically by redefining everything at runtime, over and over again ... the whole Ruby language is built from the ground up on redefining classes (for the "class" construct, defining new classes in case they don't exist, that's just a side-effect). I'm not saying you cannot build something better in Scala (time will tell), but that something has to be a lot different and a lot more effort will be required. Yeah, you can do "var a = 1" in Scala, that's nice. the path forward for programming will see a convergence between static and dynamic typing Actually the path IMHO is a bigger separation between static and dynamic, with optional static types introduced in dynamic languages as hints for performance purposes. Basically that's because OOP is inherently incompatible with static types and because type classes are inherently incompatible with dynamic types.
- shasta 16y agoIt might not cover 80% of rails, but rails isn't 100% of programming. Also, the feature lacking in Scala that would help the most with both of your examples (rails and ORM) is meta-programming, which is somewhat orthogonal to the issue of static typing. And you're right that a well designed meta-programming solution wouldn't be a clone of the Rails framework - I think it would be superior in some important ways. Why do you say that optional static typing introduced into dynamic languages is a divergence? Coupled with looser typing from the static languages, that looks like convergence to me. And what part of OOP do you see as incompatible with typing?
- bad_user 16y agoRails is just an example for which dynamic typing works great -- that's why in my initial comment I mentioned style + use-cases. Dynamic typing simply works better when you're dealing with external-interfaces that are dynamic in nature (i.e. data-structures and interfaces defined outside of your software). Web applications, because they deal with a lot of text-manipulation and because they also deal with external data-sources and multiple layers, are the prime example for which dynamic typing works best. Why do you say that optional static typing introduced into dynamic languages is a divergence? Is not a divergence per-se, but the purpose of static types is to prove correctness of types from compile-time. Dynamic languages (as they are used) only need static types for performance reasons, that's why the optimal implementation will consider these types as hints and nothing else. what part of OOP do you see as incompatible with typing A static-typing system, to function properly, must be able to trace the true type of a variable throughout the code and be able to use that type at any given time in the compilation process. In OOP you don't know the type of variables at any given time, you can only know its interface at most. And even that is incompatible with OOP, as OOP was also designed around the idea of overriding the method-dispatching being done (even in Java/Scala, all method-dispatching is done at runtime, as you're dispatching based on the implicit parameter). For example, Scala cannot implement the Hindley–Milner algorithm for type-inference, being forever forced to the current poor implementation that only deals with inferring the type of local variables. And F# / Ocaml on the other hand really have 2 type-systems in a single language (to be able to keep Hidley-Milner , with rules for interoperability. And when working with one or the other, it's like working with different languages. And the truth of the matter is, if you're watching closely, hybrid languages that are trying to combine static and dynamic really give you the worst of both worlds.
- joshsegall 16y agoI agree that both static and dynamic type systems have their place, but I think this article misses the biggest con of Scala to me: the push towards stronger typing, such as that of Haskell. I estimate fewer than 5% of programmers I've worked with truly understood type theory deeply enough to program a complex system with them properly. In addition, 0% of the systems I've worked on required such strong typing to achieve success. Typing in Java is comparatively weak, which I view as a feature because it allows you to make more practical trades between expressiveness and simplicity.