Erlang Inside header image

erlang:lists/1

Welcome to the start of the erlang:lists series where we list some interesting happenings in the world of Erlang.

erlang:lists(CouchDBNaked) - Harish Mallipeddi, a performance engineer at Yahoo, has put together a great post on the internals of CouchDB, and how to even use some of the couch source to build your own B-Tree based mini-application.

erlang:lists(ErlangFactory) - Slides and videos are up from the 2009 London Erlang Factory conference. About half have videos and most have slides available. Not sure yet if they will all have videos or if there are reasons for not showing the films for some speakers.

Each week I’ll mention a few must-see articles, blog entries or videos. If you have something to bring to my attention - contact me at chad at inakanetworks com.

Sneak Preview of O’Reilly’s new book: Erlang Programming, by Francesco Cesarini and Simon Thompson

For the past two years in the Erlang community, when someone says “I used The Book to learn Erlang,” it was an unequivocal reference to Joe Armstrong’s book by The Pragmatic Programmers. It has been the guide to learning Erlang, responsible for inducting a whole new generation of developers to the language.

Yet, now that Erlang Programming, by Francesco Cesarini and Simon Thompson, and published by O’Reilly, is out, the use of the phrase “The Book” will be followed by the question “Which One?” Erlang Programming is a worthy contender for the best Erlang book, and evidence of the growth and maturity of the community.

I received a pre-release copy of the book, which is scheduled to be published in a few weeks, and I spent the weekend exploring it.

First, the inevitable comparison between the two books. Joe Armstrong is probably best described as a prophet of the Erlang world. His book is a polemic for parallel programming in general and Erlang specifically. Why shared nothing is everything, why message passing and the actor model are important, and why ‘5 nines’ doesn’t make Erlang break a sweat. Joe set out to tell the world why any system sufficiently advanced is an attempt at rebuilding Erlang. Joe succeeded wildly - he produced a book that gently preaches and occasionally dazzles us with one line IP protocol parsing. Speaking for myself, it was the major influence that drew me into the Erlang world.

Francesco and Simon’s work is altogether different
. It’s still for the beginner, but it has the luxury of living in a world where many readers already know why they want to learn Erlang. In fact, it’s partially due to the success of Joe’s book that this one can be so good. So they don’t have to proselytize. They can teach and tell stories. We’re ready to listen and we know why we’re here.

They produced a great book. They could have titled it “Practical Erlang Programming” - its the best way to describe the book. In just a few days of reading i’ve learned practical tips on the best way to structure processes and pass requests through the system to the reason why defensive programming designed to handle every possible input without failing can make your programs much more diffcult to debug.

The book starts with a great summary of the happenings in the Erlang world in the past few years, useful to show to your boss if he’s still not sure the language has legs. Next, they dive into a summary of “Basic Erlang” - a great primer on data types, atoms, guards, lists, comparing lists and tuples, and the shell. It’s the best introduction to Erlang syntax i’ve read yet.

It moves on into a description of sequential programming, how to use case statements, guards, the “BIFs” (built in functions), and much more. It even tells us things they’ve left out because they promote bad programming practices, such as the process dictionary, which is an easy way to subvert “shared nothing”.

They provide a good intro to the Erlang debugger, and then dive into concurrent programming. The overview of message passing assumes you know why you would want to pass messages, and spends more time talking about the best way to architect a multi-process system than the specifics of low-level message passing.

A section on Design Patterns gives a great overview of the patterns used in Erlang development, including client/server, finite state machine, and event handler patterns. In general, you can tell that these guys have built a lot of real-time systems with Erlang. Tips for patterns to avoid and real-world reasons for why using a particular pattern is wise or foolish pepper the work with depth that only comes from experience.

Error Handling, dynamic functions, and OTP are all given detailed treatment in their own chapters.

Unit testing and Test-Driven development are covered in a separate chapter, with specifics on EUnit. The culture of TDD, which recently has become so popular in the Rails community, is clearly not as prevalent in the Erlang world, so it’s important that this is included.

How to interact with Ruby, Java, and C via Erlang ports is taught, along with a brief mention of how to accomplish interactions between Perl, Python, Haskell and PHP.

ETS and Dets tables are covered as well as Mnesia. The reasons to use and not to use Mnesia are explained thoroughly, with discussions on gotchas in bringing up Mnesia nodes with extremely large tables. Unfortunately CouchDB and MySQL are mentioned but using them is not discussed. This is a real world need - perhaps a whole book on data access with Erlang is in order?

The book concludes in Chapter 20 with a discussion of coding style, best practices, and optimizing programs. I can say that my Erlang code will improve just from reading this section and this chapter alone is worth the price of the book.

What did they leave out? For the beginner, one more chapter on web programming and relational database access would have been a bonus, but the book is thorough enough without it.

So which book would I recommend? If you can afford both, they complement each other well. But, if you had to buy one, I’d recommend this one, mostly because of the practicality and depth. It builds from a great introduction to the Erlang language to in-depth discussions of the most powerful parts of the platform, with a solid focus on best practices throughout. Joe’s book has made the converts, now Francesco and Simon’s equips the Erlang Faithful with the tools to conquer the world…

The Safari version of the O’Reilly work will be available around June 15th, and the print version should be available the week of June 22nd.

37 Signals, creators of Rails, embrace Erlang, where it makes sense

You may be familiar with 37 Signals, the guys who brought us Ruby on Rails, Campfire, Basecamp, among other products. Mark makes a wonderful case for using the right tool for the job in this “Nuts & Bolts” post, on how the Campfire internals work better with Erlang.

Campfire is a web based messaging/chatroom system that used a C-based polling system to determine if messages needed to be sent to connected browsers. The team replaced 240 separate C processes with 3 Erlang processes, and they explain how and why here.

Erlang Factory San Francisco Recap

Great summary of Erlang Factory San Francisco. Happy to say it sounds like a milestone for the Erlang community… Kevin’s summary “Erlang Factory rocked and you should’ve been there.” - Link

2009 Erlang Factory is Biggest Gathering of Erlang Expertise outside of Sweden

Next monday the Erlang Factory conference starts in San Francisco. If you’re in the Bay Area and can make a last minute change of plans, it looks to be a milestone conference for the Erlang community.

The University is the 27th - 29th, with the Conference from the 30th-1st. Speakers include Robert Virding, one of the inventors of Erlang, Damien Katz (CouchDB), Chris Anderson, Rusty Klophaus (Nitrogen), Yariv Sadan (ErlyWeb),  Eugene Letuchy (Facebook) and Ezra Zygmuntowicz, who will be a special treat for any fans of Ruby/Rails/Merb as he is the founder of EngineYard and a lead contributor to Merb.

Since our focus here tends to lean toward web development with Erlang, and as I’m a Ruby/Rails and Erlang programmer, I’m particularly interested in the talks by Yariv, Ezra, and Rusty. Ezra’s talk will be on Nanite, a self-assembling fabric of Ruby daemons communicating via RabbitMQ.

If you can’t make it to SF, there is a similar conference in London in June.

Looks to be an incredible conference and I’m only sad that I won’t be able to make it this year.

Erlang Inside Interviews Joe Armstrong

Writing Ruby code for a living, building a company in a foreign country, learning a human foreign language (Spanish) and a computer foreign language (Erlang) on the side hasn’t left a lot of time for blogging about Erlang. But in the past month we were able to spend a few minutes w/Joe Armstrong, creator of Erlang and certainly the language’s most famous ambassador.

In the past year Erlang has started to become much more popular - how has this affected you?

JA: I get invited to a lot of conferences - I used to say yes to every invitation I got, but this got silly. So I now only accept a few per year.

Do you get asked for autographs in the street yet?

JA: No

Seriously, does it seem like Erlang is headed the same way Ruby was 5 years ago?

JA: No idea - but scratch the surface there seems to be lot’s of interesting stuff
going on.

Related to Erlang’s increasing popularity, any thoughts on the proliferation of web platforms for Erlang?

JA: Not really - Erlang wasn’t designed for building web platforms - it was designed for building fault-tolerant systems. Where Erlang seems to excel is in instantant messaging (ejabberd for XMPP and rabbit-MQ for AMQP) and schema-free data-bases (CouchDB, Amazon SimpleDB, Scalaris) etc.

How about Reia - any thoughts about this language? It has mutable variables, among other things…

JA: I haven’t tried it - I don’t like mutable anything

When I try to introduce Erlang to developers, I often get incredulous stares because when they first see the syntax they’re overwhelmed with how unusual it looks. What do you think the major barriers to adoption are with Erlang? Is it syntax or is it unfamiliarity with functional programming? Or something else?

JA: Fear of failure - this is always why people don’t try new stuff. Functional programming takes people out of their comfort zones. Once you get started it’s pretty easy, but the step to getting started is perceived as being large.

If you could change anything about Erlang’s syntax, would you?

JA: The record syntax is a mess, I’d like to introduce hashmaps in some convenient notation …

Do you see language design as a hobby or is this the only language you’ve ever created?

A hobby and obsession. I’ve made several languages - Erlang is the only one that has escaped.

Any thoughts on other functional languages such as Haskell or F#?

JA: I like Haskell very much - not so keen on F# - By tightly integrating with .net you get a lot of benefits but this damages the conceptual integrity of the language.

Any plans for another book?

JA: I’d like to write some more programming books.

Hacker News full of Erlang articles

Hacker News’s author was complaining yesterday about a spike in traffic due to a ‘fluff piece’ on a woman building a blog to get hired by twitter. His solution - asking the faithful readership to post only Erlang stories to drive away ‘mainstream’ readers. It probably worked to drive away less hacky-readers, but probably only attracted more attention. The whole first two pages is filled with Erlang-related submissions.

Tic-Tac-Toe In Erlang

Neal over at nealabq.com has a long tutorial on Erlang Tic-Tac-Toe, which is incidentally the first program I wrote when learning Erlang. Programmers may want to take a look at the tutorial, but perhaps the most interesting aspect of the tutorial is the way he takes the problem space and shrinks it down by analyzing the algorithm and the properties of a game of tic-tac-toe.

http://nealabq.com/blog/2009/03/06/tic-tac-toe-erlang-smart-game-space/

Do you know of other game tutorials in Erlang? Send them to me or post in the comments.

The Top Ten Erlang News Stories of 2008

It goes without saying that 2008 was a difficult year for many with 2009 looking to be more of the same. But for the Erlang community, it was probably the best year since Joe Armstrong released Programming Erlang. OK, that was 2007… still, it’s a great time to use Erlang. Here are the top ten Erlang related ‘events’ of 2008, from ’smallest’ to ‘biggest’. This is my subjective ranking with a focus on the trends that will introduce the most number of developers to the power of Erlang in 2009.

10. Erlang jobs more than Quadrupled in the UK last year, according to IT Jobs Watch. I believe similar results in the US but don’t (yet) have the data to prove it.

9. Sites like LangPop.com recognize that languages like Erlang and Haskell are being talked about more than they’re being used (so far). For instance, Erlang has passed C# and Visual Basic in discussion frequency and sites such as SD Times cover more stories on Erlang

8. In the Top-Ten Self Promotion Department,  Erlang Inside releases and tries to fill the gap in Erlang related news sites.

7. Amazon uses more Erlang with its SimpleDB release. OK, this was in Beta in 2007 but not officially released until 2008.

6. Pragmatic Programmers release a set of brilliant Erlang Screencasts.

5. Reia is released in alpha, and provides a scripting language with the power of the Erlang runtime and VM, as covered on Erlang Inside.

4. RabbitMQ - See this Google Talk about RabbitMQ.

3. Nitrogen Web Framework for Erlang - As covered earlier this year, Rusty has come a long way recently with a great looking website including screencasts showing the power of the framework.

2. CouchDB - CouchDB became the schema-less DB of choice for a growing number of users, was inducted into the Apache Incubator, and everyone starts discussions about it with “Did you know it was written in Erlang?”.

1. And Finally… Facebook launches Chat to 70 Million Users… All At Once. Using Erlang. I can’t think of a better advertisement for the power of Erlang (outside of the Telco space) than the successful release of this feature.

Thoughts on this list? Missed something big? Add other ideas in the comments…

BeepBeep Is Another New Erlang Framework

Happy New Year! It’s been a great 2008 for Erlang, which we’ll cover in our 2008 Retrospective in another post later this week. For today, it’s a new, simple web framework for Erlang called BeepBeep. Written by Dave Bryson, it uses MochiWeb, which most Erlang Web developers are familiar with, and ErlyDTL, which is an Erlang port of the Python Template Language. Travis Slicegood has a demo application written in BeepBeep grabbing photos from Flickr, and Dave Bryson has a sample Blog Application as well.

The new set of Erlang web frameworks is more proof of the number of ambitious, sharp developers moving to the language is growing.