Menu
Sign In Search Podcasts Libraries Charts People & Topics Add Podcast API Blog Pricing

Simon Peyton Jones

πŸ‘€ Speaker
962 total appearances

Appearances Over Time

Podcast Appearances

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

So object-oriented programming is another approach to polymorphism.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

So in an object-oriented language, we say if we have a Ford that is a car and a car is a vehicle, then anything that works on vehicles should also work on cars and should also work on Fords.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

So

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

The code that we write for cars works unchanged for vehicles and for Fords.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Now, that's a form of polymorphism, not parametric polymorphism.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

That's what you might call object-oriented polymorphism or subtype polymorphism.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

But polymorphism in the sense that the same code, the same executable code, actually the same machine instructions work on values of different types.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Okay?

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

In both cases.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Both reverse a list, same machine instructions.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Code that works on vehicles works on things on Ford, same machine instructions, right?

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Okay.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

That's what polymorphism in general means.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Parametric polymorphism means this full A, list of A's, list of A's stuff.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Subtype polymorphism means if it works on vehicles, it works on any subtype of vehicles.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Okay?

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Now, the interaction of the two, which you get by adding generics to an object-oriented language,

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

is pretty complicated.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Oh, and by the way, adding side effects as well.

The Peterman Pod
Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Your question involving classes and superclasses and so forth is smack in that complicated world.