Programming Erlang


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.

About these ads

Tags: , ,

2 Responses to “Programming Erlang”

  1. B Says:

    ” {_,{_,{_,Name},_},_} = Person ”
    Assuming you have defined a record ‘person’, you can do something like :
    Name = Person#person.name

    “Does it solve one problem (concurrency), only to sacrifice good things like OOP?”
    Erlang is not designed to be object orientated, just like any language it is only one tool for the job and has its own pitfalls. No OOP is not a sacrifice, it was a design choice (OOP is not the One And Only solution.)

  2. jbellmyer Says:

    I agree, different tools for different jobs. However, I’m addressing the recent buzz surrounding Erlang in the Ruby community. It’s an old debate, speed of execution vs. speed of development.

    I believe most of the time, development speed is more important than execution time because cpu cycles are always getting cheaper. Development costs tend to trend the opposite.

    In the end, it’s all about cost. If something is cpu-intensive enough to warrant concurrency, then sacrificing rapid development is probably worth it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: