preface

This book is an attempt to distill what we think are the most important things a professional Erlang programmer needs to know in order to use this hugely productive programming language to its full potential. Erlang/OTP gives you a lot of power, but so far it’s been a daunting task for budding Erlang programmers to learn the OTP framework on their own by studying the documentation (which goes into a lot of detail but doesn’t show you the big picture).

The three of us have worked with Erlang for a long time, but our individual paths have been very different.

Martin: “My first ‘real’ job introduced me to Erlang programming. I had been doing C and C++, and I thought I was having fun. My first boss, Hal Snyder, who even years ago in the ’90s had a passionate dislike for threading, stumbled across Erlang. I was an intern at the time, so he gave me a project to complete with Erlang because, well, I was cheap, and if I failed, the company only lost about $70 on the deal. I didn’t fail. I wrote my own 1,000-line monstrosity of a supervisor, because I didn’t know what OTP was, and there certainly were no books about it. In the process, I fell in love with the ‘right’ way to write back-end systems, and I fell in love with Erlang. Erlang gave me the opportunity to see into the future: I wrote complex distributed systems, using advanced algorithms that my imperative language colleagues could only dream about and never implement in less than two years and a million lines of code. Thousands of pages of documentation and tens of thousands of lines of code later, I still love it. Along the way, I’ve met some great people, and I’m thrilled to be writing this book with two of them. I met Richard while speaking at an ACM conference in 2004, and I met Eric four years later as we formed Erlware—a project in which we’re opening new chapters even now. Erlang has been a big part of my professional and personal life for many years and will continue to be so.”

Eric: “I started noodling with Erlang as a side issue. I wanted to write a massively multiplayer game, but I knew that one person, even if they had a talent for it, couldn’t do the graphics for such a game single-handedly. I decided to concentrate on game play, thinking that I might be able to do this well, given the right tools and the right language. I liked the idea of agents in the game learning on their own over time, having independent concurrent actions. The only realistic way in my mind, at the time, was to model each of these agents as some type of independent concurrent thing, but I didn’t know what that was. The languages I knew wouldn’t work for one person writing a game like that all by themselves. So, I started exploring languages. I spent five years or so doing this, on and off, in some pretty extreme depth. I came upon Erlang fairly early, and although I liked the concurrency, its syntax and functional nature threw me off. It wasn’t until I had explored programming languages in general a lot more that I started to appreciate Erlang and write code in it. I never wrote that game, but after I settled on Erlang as the right choice, I delved deeply into it, explored it thoroughly, and started realizing how useful a language it was for many things. This was back in 2000 or 2001. For the following few years, I experimented and taught myself OTP. Then, in 2005, I introduced Erlang at Amazon.com, released the first version of Sinan, and met Martin Logan, and we founded Erlware. In 2008, I moved to Chicago to get the book project moving and start Erlware in earnest.”

Richard: “I was introduced to Erlang around 1995 when I was looking for a subject for my master’s thesis in computer science at Uppsala University. This led to me being part of the High-Performance Erlang research group as a PhD student, working on the Erlang compiler and runtime system for many years. I met Martin Logan and Eric Merritt through conferences in Sweden and the U.S. and was impressed by their enthusiasm for Erlang despite it being such a little-known language in those days—particularly in the U.S. During my PhD studies, I also hacked on a few side projects: the Syntax Tools library and the EDoc application were spin-offs from my compiler-related work, and EUnit had its basis in the need for me to check that my students’ concurrent programming assignments worked according to spec. After leaving the world of academia, I spent a few years working with non-Erlang-related things, coding mostly in Python, Ruby, and C++. But these days, I’m working full time with Erlang again, in the fast-moving world of high-availability payment systems, at one of Sweden’s most successful startup companies.”

We’ve tried to extract as much as we can from our collective experience in order to make your journey toward becoming a master Erlang programmer easier; and we hope that with the help of this book, the OTP framework will finally become something that every Erlang programmer knows how to use—not only those brave few who have read the manuals back to front.