Hacker News new | ask | show | jobs
by ubertaco 4050 days ago
By "a powerful type system", I mean a type system that allows you to flexibly express more-complex constraints in a way that the platform (either compiler or runtime) will catch.

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".