Saturday, November 5, 2016

Erlang and my inferiority complex against functional programming

A few weeks ago in the middle of October 2016, I had some interesting exchange of tweets inspired by an Alvaro Videla's tweet. Alvaro wrote he always told people Functional Programming (FP) in Erlang was a necessity, not part of the original design (emphasis mine).

I later found Robert Virding, one of the founders of Erlang language and concurrent system, explicitly stated in this talk (video at Functional Conf 2016) (at 4m23s) as follows:

We were not out to implement a functional language
We were not out to implement the actor model
We were trying to solve the problem

Robert's statements in the quote above are the exact reason why I started and still like Erlang.

I've already erased the tweets (I keep most of my tweets ephemeral) of my response, but I would like to write my story about FP.

My first exposure to FP was through the books of Lisp in 1980s. I didn't understand the FP principles, but I got rather interested in the symbolic processing capability and the ease of handling data structures.

I'm not interested in slow (i.e., not sufficiently fast for a purpose) systems. In 1980s Lisp systems were running mostly on interpreters, so I have a strong recognition bias that tells functional languages are slow, which is incorrect as of 2016; a counter evidence is shown as a production level documentation tool written in Haskell called Pandoc, and by compiler-based FP systems such as Common Lisp. Nevertheless, in 1980s, FP systems were mostly slow. Until the late 2000s, I hadn't been really interested in FP again.

I've got a very strong inferiority complex when I tried to study something about FP and Lisp from 1988 to 1990 at a university laboratory where the main research topic was about the programming languages and paradigms. I utterly failed, because my main interest then was how to connect the people in Japan and the world, through email, USENET (NetNews), UUCP, and affordable TCP/IP links.

My inferiority complex against FP is still not gone yet. Three PC member roles, Two accepted papers, and one workshop chair role (in 2011) for ACM SIGPLAN Erlang Workshop events were something I would have least expected in the late 1980s or early 1990s. FP people are generally much smarter than me and they are amazing. I have been lucky to meet the talented and productive researchers, including John Hughes, Simon Thompson, Kostis Sagonas, and many others (which I'm very sorry to omit their names here).

On the other hand, however, I still have some feelings that some FP people are too theoretical and not respecting well on practicality of currently programmed system, when I am watching on (mostly Japanese) FP communities, especially those on Twitter. My gut feelings are like this: Theory is nice. Theory is beautiful. Beauty is important and often essential in programming. I think that's what academic and research communities for software are for. But the real virtue of programming prevails on how it solves the real-world issues and problems. There's no side-effect-free world so long as having to deal with I/O devices. Memory is limited. CPU speed is limited. Network bandwidth is limited. Isn't FP a way to deal with these real-world limitations while maximizing the ease of abstraction on programming? (I think Object-Oriented Programming (OOP) is also trying to solve the same issues, but that's another issue; I still need to understand why Java/C++/C#-like OOP languages are simply that much complex.)

Erlang has been one of the rare language systems which didn't impose or force me to do the things in "functional" way, though the FP principles are embedded deeply in the core, such as the immutability and no-shared object/process principles. I think Elixir follows these principles well, though I see some interesting FP technologies in Elixir such as macros and metaprogramming. In short: Erlang (and Elixir) didn't trigger my inferiority complex against FP!

So some trivial lessons I've learned:

  • You are never too late to learn new paradigms.
  • You are never too late to re-learn things once you failed to learn.
  • There's something fits for you even for a category you don't feel like to study.

I think my inferiority complex against FP will stay until I die, but now I don't have to feel FP is not my stuff. And that is good.