Never put the Lego away!

Posted on September 13, 2013

For a few years I earned my way as a Drupal Developer, both as a salary man and as a contractor. It was my first role as a ‘professional’ programmer, I was fortunate to have some truly amazing mentors during this process and hopefully they haven’t created a monster.

It wasn’t long before I stumbled into the land of milk and lists and discovered functional programming. This was a real discovery for me because at no point during any of my programming courses do I recall anyone mentioning it. We started with Python, moved to C#, one course used Java, and another used C++. Finding out that there was this alternative paradigm for expressing your ideas and solving problems was eye opening to say the least…

Unfortunately for my coworkers I never stopped bringing it up….

The first discovery was Clojure and various other Lisps after that.. Scheme, Racket, Common Lisp. I became inspired, once I started to understand bits and pieces I was amazed at the problems I could solve with such clarity and inherent simplicity.

<?php

$list_of_things = get_my_list_of_things($some_args);

for ($i = 0; $i < $some_limit; $i++) {
    $list_of_things[$i] = do_some_work_with_thing($list_of_things[$i]);
}

return $list_of_things;
?>


(defn do-some-work-with-thing [thing]
    (compose sauce tomato cheese thing))

;; I mean REALLY...
(map do-some-work-with-thing (get-my-list-of-things some-args))

I kept experimenting and learning, picking up a copy of Joy Of Clojure and starting to dig deeper. I joined a mailing list through We’re Probably Wrong for a reading group and we all started to go through it together, sharing problems and answers. Helping each understand the language and the new concepts we were being exposed to. We set some more advanced problems as well and it was great to see all the different solutions that people came up with.

I have a skeleton of an Othello game written entirely in Clojure sitting on my Github account which, despite being unfinished contains some of the code I’m most proud of. Not because it’s super incredibly fast, or because it embodies the ideals of Lisp, or even because it’s idiomatic Clojure code (it’s not). But I can’t remember having that much fun trying to solve a problem using code.

I had to think about what I was doing and whether that was a good way to deal with the problem at hand. I found the details about how to go about it just fell to the way side. The language simply complied with my needs and didn’t get in my way. It was liberating, and I hadn’t even hit the chapter on macros yet!

This sort of mad scientist attitude didn’t abate either, I’ve since begun to learn Haskell, Erlang, and I’ve a teeny tiny contribution pending for Lisp Flavoured Erlang. These languages are incredibly fascinating and so inexplicably powerful. Most important of all is that these languages are FUN. Fun that I could not discover in Java or C, fun that was drained from JavaScript as people constantly argued about design patterns and introduced another framework that would make developing ‘powerful and flexible and response webapps’ easier than any other framework… Again…

I’ve barely begun to scratch the surface with these languages, but I don’t see the fun ending any time soon and it all feels like play. I’m not just writing code to solve a problem, I’m dabbling in unique forms of expression that feel designed to let me create a my own form of expression that is purpose built for my problem. As opposed to feeling like I have to colour by numbers and hope that my problem can be solved before I run out of boiler plate.

This isn’t to say the other languages are incapable, far from it! Clojure is implemented on the JVM after all. But for me they do not create and empower the sense of play that these other languages provide. Even when Haskell is throwing me down the stairs because I can’t seem to understand what it’s telling about what I’ve done wrong. >.>

Refactoring code in Clojure/Haskell/Erlang/LFE is also interesting and engaging because it’s just a chance to see just how much I can improve what I’ve done without breaking anything. It’s a chance to learn/practice language features, techniques, etc.

Many of my code inclined friends have had to endure me harping on about how interesting and powerful these languages are. Not because they’re just a different language but because of how they change how you approach problems. Your brain starts to move in new and interesting ways. It excites and fascinates me and I dearly want to share it with them. (see what I mean)

I’ve had people tell me to pick a language, or not bother with any of these because X language is the future/better for finding a job. These statements come from people whose opinion I value, highly, but often these are the same people that aren’t interested in learning or looking any other language than the one they’re currently using.

I also don’t know how to pick just one of them because they each provide such an interesting take on problem solving that picking only one seems like doing myself a disservice.

  • Clojure : My first functional language experience and still my stand out favourite. Wonderfully elegant, simple to learn initially but with such power and flexibility it’s unlikely you would cease to find new and useful ways of solving problems.
  • Haskell : For me this language is a tough taskmaster, but at the same time as my understanding grows I see it trying to help me at every turn. This language is growing on me in a big way.
  • Erlang : It’s impossible to not like this language, I think. You can grok it’s syntax in the same amount of time as a Lisp, but discover yet method for solving problems, then realise that almost by design you’ve gained the ability to run that solution in a distributed environment (kinda).
  • LFE : What applies for Erlang applies for LFE with the added joy of it being a Lisp. Although it is another to speak Erlang, it brings so much of the power of Lisp with it. (Nearly all I think…)

Every time I have to use PHP/Java etc I instantly find myself wishing I had pattern matching, better recursion support, immutable variables, and all the neat advantages I gain in the other languages.

But most of all, I miss the fun.

Manky.