Hacker News new | ask | show | jobs
by andybak 3690 days ago
Modern static typing isn't remotely related to typing from the "1970's"
2 comments

Well, depends on what you mean with modern static typing. In some ways, mainstream programming is finally catching up with ML, which is from the 1970s.

If you mean cutting edge PL research it's a different story of course.

The type systems in modern languages like Swift, Rust, Scala, Haskell, and even Kotlin go way beyond classical Hindley-Milner. Classical Hindley-Milner gives you parametric polymorphism over algebraic data types, along with an inference algorithm. No subtyping, no casts, no coercions, no overloading, no polymorphic literals, no interfaces. You basically get SML.

Consider that in 2006, MPTCs with fundeps was the preferred way to represent "a collection of items that can be compared via equality" [1]. Associated types were a vague research idea [2] that showed a lot of promise, but hadn't been implemented in any language with type inference (they did exist in C++ templates, but C++ isn't exactly what people think of when you say "modern type system"). Now both Rust and Swift feature polished implementations of associated types and use them pervasively in the standard library.

[1] https://en.wikibooks.org/wiki/Haskell/Advanced_type_classes#...

[2] https://prime.haskell.org/wiki/AssociatedTypes

> You basically get SML.

SML is still more usable than the statically type languages in use the most today (C++ and Java).

Yes, but by "modern static typing" I think we're talking about the latest generation of languages that have come out since 2010 (Swift, Rust, Kotlin, etc.)