|
|
|
|
|
by scala8
4050 days ago
|
|
What do people mean when they say "powerful type system"? Does that mean it could potential be a downward spiral where everyone creates their own DSL? I use Ruby on Rails and Django - and in ruby and python, it's interpreted on the fly. How will a type system, let alone a "powerful type system", help improve ruby or python's web apps? |
|
For example, Javascript's type system (such as it is) is not, in my opinion, as powerful as Java's -- since there's no compile-checking and the runtime coerces stuff all over the place and does basically no checking at any point.
Python's is somewhat better: there's runtime-checking, but it's duck-typed -- so you could call some array methods on an instance of, say, "FootballField" just because the FootballField has a "__len__" property and the runtime wouldn't catch it.
Java's type system is a tiny bit more powerful -- the compiler does a lot of checking for you (so you can enforce that a method must take an array or a List<something>), but it's not as flexible (until JDK8, there was almost zero type inference, so you had to be super-explicit everywhere).
Scala's type system is more powerful still; traits allow you to describe similar classes in a duck-typed-esque way (without the classes themselves having to opt-in), and there's really good type inference.
I'm not an expert in Scala, so I could be wrong about some of its features in particular, but that's the sort of thing that I mean by "powerful type system".