Structural typing (and its integration with prototype OO) might be one way to address the platypus problem.

Instead of taking the John Wilkins / Aristotle / Bertrand Russel view of categorization (wherein there is some underlying and non-contradictory hierarchy of categories that we can discover — an ontology that must exist because real things emerge out of platonic forms), we take the Wittgenstein / Korbyzki / Bucky Fuller / Robert Anton Wilson view (wherein categories are a convenient way for humans to chunk data when dealing with a chaotic universe but all things are essentially platypi in a sufficiently granular category system). So, instead of creating category names and then assigning type names or class names to them as children in the hierarchy (i.e., nominal typing), we define rules for what constitutes a category & anything that satisfies those rules is considered by the compiler / type checker to be part of that category.

In its purest form, structural typing is a kind of compile-time version of duck typing, although you can make it more conservative. (Duck typing determines compatibility based on the attributes necessary for a particular method to run. But, structural typing is also compatible with the idea of declaring a parameter as being of some type or set of types & having all the constraints of those types checked. The difference is that the object being passed in doesn’t need to have its compatibility with those types declared, as (for instance) java classes must be declared to implement particular interfaces. In nominal typing, just implementing an interface is not enough — you must also advertise that you implement it.)

I’ve seen structural typing become more popular as ideas from statically-typed functional languages make their way into other spheres, and I think it might even be possible & useful to mix structural and nominal type systems (i.e., to have a way of declaring structural types and a way of declaring nominal types, and a checker that can combine both kinds of constraints), though I’m not aware of anything that does that yet.

Written by

Resident hypertext crank. Author of Big and Small Computing: Trajectories for the Future of Software. http://www.lord-enki.net

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store