Archive for March, 2008

RESTful Services with Erlang and Yaws

March 31st, 2008  |  Published in erlang, REST, services, yaws  |  Bookmark on

Today published a new article I’ve written entitled “RESTful Services with Erlang and Yaws.” Stefan Tilkov recently asked me if I had anything to contribute to InfoQ, and I thought an article on that topic might be interesting, as I hadn’t before seen anything covering REST and Erlang together.

I think it’s one of those articles that could be much, much longer and far more detailed if space (and time) permitted, but hopefully there’s enough there to whet your appetite if you’re considering developing RESTful web services in Erlang. I really can’t say enough good things about using Erlang and Yaws for this purpose — it’s quite a solid platform.

I’ll be giving a talk on the same topic at both JAOO Brisbane and JAOO Sydney at the end of May and beginning of June, respectively.

WS Time Warp?

March 21st, 2008  |  Published in distributed systems, REST, WS-*  |  Bookmark on

Either it’s suddenly become 2004 again, or somebody didn’t get the memo. It’s hard to choose where to begin with this one — hmm, maybe this little tidbit:

Now here’s the absolute coolest part (at least in my opinion). Armed with the WSDL document, you can use freely available, open source tools to automatically generate stub code to send requests to and receive responses from the SOAP web service in just about any modern programming language of your choosing.

For both the client and the server.

The stub code generates and parses all of the XML. As a developer working in the language of your choice, you are completely abstracted from the sending and receiving of data on the wire.

I guess I was wrong; it’s not 2004, it’s 1994.

Back from QCon

March 15th, 2008  |  Published in commentary, conferences, erlang  |  Bookmark on

I just returned home from QCon London, and its excellence exceeded my expectations. As usual, the quality of speakers QCon attracts (just like JAOO) is outstanding, and they cover a very wide variety of topics.

Kent Beck‘s keynote was excellent. It was about developer responsibility, developer integrity, and the relationships developers have with those around them (here’s a good summary). Extremely insightful, not unexpectedly of course, and covering important topics that are unfortunately often taboo among technical folk.

It’s been awhile since I spent any quality time with Kent, but we did manage to sneak off to a back room at the speaker party on Thursday evening and get 20 minutes or so of conversation in, which is better than nothing. Given that the first two to drop in were Jim Webber and Joe Armstrong, though, neither of us minded the extra company. Generally, though, I think I could easily spend a couple solid days talking to Kent about development issues.

I spoke in Stefan Tilkov‘s track on Thursday, and I thought it went OK. Stefan has already provided detailed notes on each talk (except his own, which was really good) on his blog, so I won’t bother with repeating any of that. I got to meet Paul Fremantle in person for the first time, which was nice, though I have to say I remain puzzled by his “REST is too hard for the average developer” claim he made in his talk, since it definitely doesn’t match my recent experiences with watching others learn it and apply it. I’ve heard Sanjiva say the same thing before as well, so I wonder if it’s just something they keep telling themselves, hoping it will come true if they repeat it enough. ;-)

On Friday I thoroughly enjoyed Simon Peyton-Jones‘s Haskell talk and Joe Armstrong‘s Erlang talk. Both were excellent speakers, and both talks ventured into areas that I’m sure many of the attendees were not familiar with, so I’m sure most everyone who listened learned a lot. Thankfully there were no “Haskell vs. Erlang” wars, but that’s not surprising given that Simon and Joe are friends, plus they know that that argument serves neither language.

The best part of the week, though, was getting to meet and hang out with Joe and other Erlang folk. Joe’s really an excellent guy. He’s quite energetic, and his brain just doesn’t stop. He’s curious about a lot of technical things beyond Erlang, and I found discussions with him to be full of interesting questions and insights. Given the fact that I work with Erlang quite a lot these days, my hope going in was simply that I’d get a chance to just say hi to him, but I turned out to be lucky enough to spend many hours with him over the course of the conference. I also met Francesco Cesarini, a well-known and long-time Erlang consultant, whom I’m sure has probably forgotten more Erlang than I’ve learned so far. I also met Alexis Richardson, who works on RabbitMQ, the right way to implement AMQP. Francesco graciously invited me to speak at the Erlang Exchange this summer, so I’ll be seeing them all again before too long to talk even more about what’s quickly become one of my favorite programming languages.

Congrats to Floyd, Kresten, and the whole QCon team for putting on yet another excellent conference. I’m looking forward to JAOO Australia (in both Brisbane and Sydney) next!

Damien Katz Criticizes Erlang

March 10th, 2008  |  Published in code, erlang, functional  |  Bookmark on

Damien Katz has been using Erlang for CouchDB, and has posted some criticisms of the language and runtime based on his experiences with them. Erlang, like any language, has its issues, and Damien’s criticisms are mostly reasonable and are worth reading. Well, except for this one:

Immutable variables in Erlang are hard to deal with when you have code that tends to change a lot, like user application code, where you are often performing a bunch of arbitrary steps that need to be changed as needs evolve.

In C, lets say you have some code:

int f(int x) {
x = foo(x);
x = bar(x);
return baz(x);

And you want to add a new step in the function:

int f(int x) {
x = foo(x);
x = fab(x);
x = bar(x);
return baz(x);

Only one line needs editing,

Consider the Erlang equivalent:

f(X) ->
X1 = foo(X),
X2 = bar(X1),

Now you want to add a new step, which requires editing every variable thereafter:
f(X) ->
X1 = foo(X),
X2 = fab(X1),
X3 = bar(X2),

If you had to write that code the way Damien did, then yes, that would suck. But here’s a better way to write it:

f(X) ->
    lists:foldl(fun(F, Last) -> F(Last) end,
        X, [fun foo/1, fun fab/1, fun bar/1, fun baz/1]).

This code applies the anonymous function passed as the first argument to lists:foldl for each element of the third argument — the list of funs, Erlang-speak for functions — starting with the value X as the value passed as Last and using the return value of F(Last) as the next value of Last. The overall return value of lists:foldl is the final value of Last. With this approach, modifying the functions applied to X also requires editing only a single line, specifically the list of funs.

In general, if you’re used to imperative languages and you find yourself writing step-by-step Erlang code like in the original example above, think functions and lists instead.

P.S. If you’ve never seen it, read Damien’s Signs You’re a Crappy Programmer (and don’t know it). One of my favorite blog postings, and I especially like the first two items in his list.