A Minor Erlang Rant

In an earlier post, I compared node.js to Erlang: https://journal.dedasys.com/2010/04/29/erlang-vs-node-js – which admittedly has a whiff of apples and oranges about it.  Still, though, I think there's something to it.  Node.js is creating lots of buzz for itself these days.   Some of that will turn into actual production use, and at that point actual companies will have a vested interest in seeing the system improved.  Currently, it is not as 'good' as Erlang.  Erlang's VM has a built in scheduler, so you simply don't have to worry about manually creating bite-sized chunks of processing that feed into one another, it all "just works".  For instance, my current Erlang project involves reading from twitter's stream, and distributing that to IRC and the web.  It's pretty simple, works well, and is quite robust.

I haven't had the best of days though, and one little annoyance of the many I dealt with today really caught my eye.  I need to do an HTTP POST in Erlang, and:

  1. The documentation does not have examples.
  2. Here's an example of how to do a POST:
    http:request( post, { "http://scream-it.com/win/tests/posttest.cfm", [], "application/x-www-form-urlencoded", "x=2&y=3&msg=Hello%20World" }, [], [] ).

  3. Aside from being ugly and not very leggible, you'll note that he's passing the parameters as a string, and also has to manually include the "x-www-form-urlencoded" header.

  4. To create that string, you'd want to url encode it.  Actually, ideally, you'd just pass in a list of key/value pairs and let the library module handle it.

  5. However, there's nothing in the http module that does that.

  6. If you look through various bits of Erlang code on the web, you'll note many, many versions of url encoding and decoding, because the http module makes no mention of how one might go about doing so.

  7. It turns out, that the edoc_lib module does have a uri encode function!

  8. That isn't documented in its own man page.

  9. And certainly isn't linked to in the http page.

So, in 2010, doing an HTTP POST in Erlang is still a pain in the neck.  I'd be happy to put my money where my mouth is and submit a patch (at least one for the documentation), but you have to wonder why no one has fixed the problem so far – maybe they're not very accepting of patches?

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 )

Facebook photo

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

Connecting to %s