Posterous

Voodoo Tiki God

I am Zero Cool

« Back to blog

How to learn Erlang (or any functional programming language)

If you are looking at learning Erlang, or any functional programming language, I recommend the following key things to remember and do, ideally in this order:

  1. Find someone just as crazy as you (with respect to wanting to learn Erlang) and establish with them a day of the week that you are going to meet up and hack Erlang together. This does not have to be just one person, but it has to be more than yourself. The reason for this is that Erlang is complex and designed less for developer happiness, like Ruby, and more for the science and math involved. In this sense most of the current documentation (though it is changing) reads less like a wild ride through happy land and more like a school textbook gone wrong. The concepts are complex and dive deep quickly, so if you try to learn by yourself you are more than likely going to succumb to the "ah crap, I don't get it" syndrome and not get to the beautiful code that you were promised you would find. Note: while it may seem like a great idea to "fast track" your learning by partnering with an expert, I do not recommend this. Once someone hits the functional programming nirvana/epiphany, they are henceforth changed and cannot talk of how they got there. I recommend not fast tracking your learning, do it at your level and pace otherwise your brain might explode and I doubt anyone would want that.
  2. FORGET ALL YOU LEARNED WITH OBJECT ORIENTED PROGRAMMING - This one is the hardest to do, so I might add a colloquy to the previous item that you should find someone who compliments your knowledge of OOP (he knows it, you don't or vice versa) and help each other. The Object Oriented paradigm is not conducive and most times destructive to learning and understanding any functional programming language. Consider it as a fork in the road after the rise of imperative languages and OOP had a better marketing team, which is why most of the commercial world uses Java and most universities use Haskell, Erlang, or Lisp.
  3. A lot of people complain about the Erlang's syntax when they first start using it -- deal with it. It is complicated and seemingly convoluted, but the more you write it the more natural it becomes. It will take a while for any of it to make sense, but that's because you are learning so much all at once (functional programming concepts, concurrency, a new syntax, coding without an IDE [gasp]). Its OK to be out of your comfort zone, its part of the experience. In part having the funky syntax is helpful because you are not continually trying to "mental map" one concept to a known one, which without fail will result in problems. The syntax is like sushi, first time you saw it you thought "ugh, dead fish", now you think "yuuuummmm, dinner" (experiences may vary, please use food that most applies to your situation).
  4. Do not be afraid to ask questions. Remember the last time you learned a whole new programming paradigm? Yea I would guess its either burned into your memory as a horrible time or it never happened. The jump to functional programs and their "math-style variables" is a complex learning process. I recommend using any and all available channels to ask questions (IRC, Twitter, IM, Email), but DO NOT EVER ask to be taught. Come with a specific "What the hell is going on here" question and work through the problem with the person, do not ask questions like "I don't understand Erlang's message passing" or "What is up with the bang(!) symbol?", use the book. This is not by any means Erlang specific, if you want to make friends not enemies in your new language du jour, do all you can on your own before you ask (RTFM comes to mind). Admittedly some people are not book readers and some books are not that helpful to read, luckily the Erlang and Clojure groups have an increasing amount of multi media presentations that facilitate more audial or haptic learning. Which brings me to
  5. Using the book for Erlang is not as easy as it might seem. The currently available book reads less like a standard sequential learning process and more like an Erlang program. Parts reference other parts all over almost to the point where you have to read all the chapters in parallel to comprehend the subject matter. This isn't a knock on the book, its a very good book with a lot of content, its just not very fluid in its conveyance for your standard object oriented programmer. If you can afford it, I recommend getting the often over looked (and rather expensive -- last I checked its $229USD used) textbook from 1992, its chockful of goodness. Think of the book as a guide to the basics and then once you get over the aforementioned syntax spike, switch over to the videos that are out - they are awesome (Great Job Kevin Smith). SHAMELESS_PLUG Also, if you don't mind, keep checking here, I am going to post more of our notes from learning Erlang in a group setting at Northern Virginia Languages and so forth.
Finally, stick with it. Its worth it even if you never ever program an Erlang application in your life, you will be changed when you go back to writing your applications (or at least thankful). The journey is worthwhile.

Loading mentions Retweet
 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     twitter