Re:Fizz Buzz: Enterprise Edition
by recursive on Monday March 18, 2013 @02:58PM
(#5396363)
Statically typed programs are longer because they contain more information.
[ Parent
| on HN ]
they don't contain more information. they contain more explicit declarations of that information. dynamically typed languages leave that information hidden because it is inferrable (or irrelevant).
>dynamically typed languages leave that information hidden because it is inferrable (or irrelevant).
So do good, high-level statically typed languages, i.e. the kind with type inference. Like Scala or ML.
indeed. Scala's type inference system is truly beautiful. lets hope it catches on and becomes a widely adopted feature of the next generation of languages.
If you want to see a really beautiful type inference, take a look at Hindley-Milner. Not only is it global (it infers all the types in your program) but it's also surprisinlyg simple--it's basically just a straightforward constraint satisfaction problem.
In particular, take a look at how it has been extended by real languages, especially OCaml. OCaml has some very cool sub-typing features but manages to maintain global inference, unlike Scala. (Largely by choosing structural rather than nominative sub-typing.)
So some languages have had better type inference for longer than Scala has been around.
When the programmer is the one that has to be doing the inference you refer to, there seems to be a good argument that the speed advantage you refer to is only apparent in programs small enough to conceptualize in their entirety.