Every few years I feel like learning a new programming language. After some thought and an amazing synchronicity I have decided to learn Clojure. Functional programming has become popular. I learned Lisp in college and loved it. Clojure derives from Lisp, and runs on the Java virtual machine, making it cross-platform. The thought of doing everything in Lisp again excites me.
John McCarthy invented Lisp in 1958, making it the second oldest programming language still in use today. Lisp stands for List Processor, because the linked list makes up the major data structure. I learned it in college for my artificial intelligence class. I got really into it. I felt its natural simplicity and organic beauty. I imagined Lieutenant Commander Data written in it. Lisp would change the future!
I went to college in in the late nineties, sort of a dark time for LISP and artificial intelligence. As a result my interest declined and I learned other languages, such as Perl and Ruby. I don’t regret this. They call Perl the duct tape of the internet. Ruby has a concise and beautiful syntax, and RubyMotion has opened some interesting doors for me. Still, I felt the time had come to learn a new language to keep my brain active and thinking in new ways.
Functional programming has gained popularity in recent years. It has existed for a long time, but renewed interest has come from needing to write code that runs on parallel processors and perform concurrent operations. It also requires a different way of thinking about solving problems. Pure functions take a set of values and return a value. They have no side-effects. You can use them as you would any other piece of data, which means you can do some really cool things with them. You can use them as arguments to other functions, or store them in a table. You can also compose functions based on other functions. Some of this might sound familiar if you’ve studied Algebra.
I therefore decided that I needed to learn a functional programming language. You can certainly use these elements in other languages, but mixed in with other paradigms. I wanted to feel a purity and clarity of logic. I first tried learning Haskell. It warped my brain in a nice way, but I stopped right before monads, something everyone warned me about.
Then I read a random tweet about Clojure. I had heard of it, Lisp for the Java machine, but hadn’t paid it much attention. I remember a talk given by Charles Nutter, about JRuby, so understood the advantages of building a language on top of a virtual machine. Then I remembered all the magical times I had with Lisp and the good memories came flooding back. I had found my perfect functional programming language! Its rationale makes everything very clear.
Lisp has a unique syntax. Most languages try to have syntax that reads somewhat like a natural language, and may have different syntactic rules for different things. For example:
- test_function( argument_1, argument_2, argument_3)
Lisp on the other hand represents all code as a list where the first argument represents the function, and the remaining arguments represent the arguments past to the function.
- (+ 2 3)
- (test-function argument-1 argument-2 argument-3)
- (def a (+ b c))
Note the nested lists. This has a natural symmetry and an organic beauty about it. No one has ever created a language like Lisp, and no one ever will. It has endured for a reason. It would not surprise me if we still used some variant in a hundred years.
Most programming languages have different implementations for different platforms, such as Linux and Windows. Clojure relies on the Java virtual machine to handle all the low level stuff. Sun designed Java as a cross-platform language. Clojure brings a modern version of Lisp to Java.
I quickly found the book Clojure for the Brave and True. . It has an easy-to-read style, a refreshing thing for a book about such a heavy topic. Coming into it with a rusty knowledge of Lisp has helped. So far I have made it to the end of chapter 3, and I completed all six of the exercises. It has me off to a good start.
I tweeted that I had decided to learn Clojure. Joshua Ballanco responded by sending me this graphic classic scene from Indiana Jones and the Last Crusade. “You chose…wisely.” The video inspired me. It captured the feeling perfectly. Indy found the true Holy Grail!
The next day, Philly Touch Tours had a handling session before a lecture at the Penn Museum. The lecture discussed Adapa, a Mesopotamian demigod. While fishing, the south wind overturns his boat, so becomes angry and breaks the south wind’s wings. This causes the wind to stop blowing, and he realizes that he must atone.
His father, the god Ea, warns him that when he goes to the gods, they will offer him the food and water of life. He must refuse, for they will try to trick him by giving him the food and water of death instead. Adapa goes to see the gods, and sure enough they offer him the food and water of life. He heeds Ea’s advice and refuses, then hears laughter. The gods actually offered him the genuine articles, and by refusing them he must return to Earth a mortal.
The museum brought some special artifacts from their collection for us to touch. We touched a clay tablet with intricate cuneiform. We held a beautiful smooth foundation stone. I had a Steve Jobs moment handling an ancient clay stamp, complete with handle. It felt ergonomically perfect in my hand, and I understood the tool’s function. The design still worked thousands of years later. I felt a powerful connection handling a tool used by an ancient people.
We touched a large clay brick like those used in the construction of a temple. I thought to put it to my nose and lightly smell. I faintly caught the scent of aged earth. I felt transported back in time. I smelled ancient Mesopotamia.
Finally we had pieces of pita bread representing the bread of life, and a chalice (really the jar of a canopic jar) filled with water, representing the water of life from the story. I nibbled on some bread, enjoying the tour. As they passed around the chalice I suddenly remembered the scene from the previous night. As I sipped the water of life I felt a new power surge through me. I knew that I must learn Clojure.
As the book says at the beginning: Deep in your innermost being, you’ve always known you were destined to learn Clojure. I had a very powerful synchronicity which confirmed this for me. Something amazing will happen as a result of this choice. Using a Lisp again also has a rejuvenating quality for me, since I learned it in the past. I’ve also gone back to using Emacs, and using a text environment written in a form of Lisp to edit and manage code written in another form of Lisp seems somehow right.</p>
This gives me an interesting feeling that I can’t quite explain, like the wonder of childhood mixed with the thrill of the distant future. I don’t know why I feel this way, but I will follow my bliss. The Goddess prevails! So does Lisp!</span>