Simon Peyton Jones
π€ SpeakerAppearances Over Time
Podcast Appearances
I'll produce a list of integers.
You give me a list of characters?
Fine.
I'll produce a list of characters.
Notice that's much better than just list to list.
I want to keep the fact there's a list of integers, so I know if I apply, when I look inside the list, I know I've got an integer.
Also, if I just list the list, I might get back a list of some completely different type, but I know that reverse returns a list with the same type of things.
Parametric polymorphism, super valuable.
If you want a static type system, you must have parametric polymorphism.
The message is,
If your type system is too simple, it gets in the way.
Very important lesson because it means that we cannot really say is a type system useful or not unless we say which one because we know that weak type systems are very inconvenient.
It must at least have parametric polymorphism.
And that is another idea that was born in the world of functional programming.
It was born in ML, incidentally.
Robin Milner's famous dictum, world-type programs don't go wrong.
ML was, I think, the first parametrically polymorphic programming language.
But generics in Java and object-oriented programming more generally is exactly the same idea.
Okay, but so now you're into a whole more complicated world, right?
So as soon as you say class, you're talking static type system again, right?