6 ms·
Crystal's type inference is more powerful than most other languages. Maybe the most powerful of any fully statically typed language? (I would love to hear of an
by Trasmatta 6y ago
Crystal's type inference is more powerful than most other languages. Maybe the most powerful of any fully statically typed language? (I would love to hear of any others that have taken the same approach as Crystal.) You can almost write Crystal like a dynamically typed language, and yet everything is still fully statically typed.
I believe you can speed up your compile times a bit by being explicit with annotations (which I often prefer anyway), but there's still a lot of overhead for the global type inference.
- fishmaster 6y ago> Maybe the most powerful of any fully statically typed language? Compared to Haskell, Ocaml, Scala, F#, ...? Writing it like a dynamically typed language is standard for full type inference.
- asterite 6y agoThose functional languages don't have function overloading or named arguments. The type inference in Crystal works very differently. The type of a method can only be computed from explicit calls to it. In those functional languages the type can be computed independent of a call because it's trivial to do so if a function name always refers to a single entity.
- Zababa 6y ago> Those functional languages don't have function overloading or named arguments. Scala has both, F# too (though function overloading is possible, I think it's not idiomatic), OCaml has named arguments, Haskell has overloading.
- Trasmatta 6y agoI should have qualified that statement with OO languages, not functional. Also see asterite's reply, he would know much better than me, as I believe he's one of the core Crystal developers.