Epiphany: Types are Orthogonal to Functional Dispatch

Most people are most eloquent in their native tongue and the same seems to be true of programming languages. There are those polyglots that excel at any language they learn but it is often more true than funny what they say about  a good Fortran programmer being able to write Fortran in any language. Only in my case I would have to substitute C for Fortran.

Many years of study and coding in Java, Ruby, Python, Lisp, and various other languages has softened my C accent but it is there for those that know to look for it.

I think it can also be said that the first language in which you encounter a particular paradigm colors your attitude toward that paradigm. For instance, I first learned about object oriented programming in Java. Soon after I encountered it in CLOS, the object extension to Common Lisp. I struggled mightily to understand CLOS. Now, some thirty years later I have realized why I had problems understanding it.

Java, like most of the strongly typed, statically compiled languages, tries to constrain functions that operate upon an object to be encapsulated in it’s class. CLOS, on the other hand, considered classes to be an extension of data types. Methods, with their type driven dispatch, were independent from classes.

Eventually, I grasped how methods worked in Lisp. It was a long time until I was comfortable with it though and I still catch myself falling back into conflating types with method encapsulation.

So, I was thrilled to discover that Julia followed the CLOS model of specifying data hierarchy with object types and letting method dispatch be orthogonal to them. There is much to be learned from such an elegantly designed language.

I obsess like this with each new programming language that incorporates what we have learned about expressing ourselves about data and functions in ever more eloquent fashions. It is part and parcel of my infatuation with programming languages. In that, I hope you will indulge me.


Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

%d bloggers like this: