Posts Tagged ‘Erlang’

Programming Erlang

March 23, 2009

Some of my Kansas City Ruby friends have started a buzz about Erlang. I’m a die-hard rubyist, but for the first time in my life I can see that I was a die-hard C/C++ programmer before Perl (tried to write CGI apps in C!), and I was a die-hard Perl hacker before Ruby. And it’s not a matter of abandoning Ruby at all – it’s more a matter of adding another shelf in my developer’s toolbox, so I really can pick the best tool for each job.

What I’m doing about it

I recently bought the e-book Programming Erlang by Joe Armstrong. It’s from the good people at Pragmatic Programmers. I’m viewing Erlang with a skeptical eye at the moment, so I got a book I know I can trust. If the Pragmatic Programmers can’t get me to fall in love with Erlang, I’m probably not capable of loving it. Also, it’s under $23 to download!

What I like so far

I’m two chapters into the book, and I believe (although just peripherally) that Erlang can solve a lot of concurrency issues. This has great potential due to multi-core, multi-processor machines. It also transcends one single machine, and allows easier networking of many machines to do whatever it is you need multiple machines for.

What concerns me

So far, reading this book has raised more questions than answers. That’s to be expected – the first couple chapters give you the elevator pitch for Erlang, and jump into some code samples to begin teaching the language. So the amazing benefits won’t be visible for a while. Knowing/hoping that these concerns and questions will likely be answered as I learn Erlang, here they are.

Concerns

  • The code doesn’t seem as elegant as Ruby. I see examples like {_,{_,{_,Name},_},_} = Person. to do what person.name would do in Ruby, and I cringe. To me, this looks like a workaround for not having objects. One that could become very cumbersome.
  • Variables can only be assigned once. This is supposed to ease the mechanics of an inherently multi-threaded language, and maybe it does. And maybe the coding style you use for Erlang makes this trivial.

Questions

  • Does the code end up being readable to others, or yourself in 3 months?
  • Does it solve one problem (concurrency), only to sacrifice good things like OOP?
  • Is there a testing framework so I can keep doing TDD/BDD? I haven’t seen mention of it yet if there is.

Again, I know Erlang is not just a different language, but a different programming concept entirely from Ruby. So I’m going to give it every chance, and keep posting what I learn.


Follow

Get every new post delivered to your Inbox.