REST

mimeparse in JavaScript

December 19th, 2008  |  Published in code, javascript, REST, web  |  Bookmark on Pinboard.in

J. Chris Anderson has ported Joe Gregorio‘s mimeparse to JavaScript, available for download here. Joe wrote the original in Python, then others added Ruby and PHP versions, and then a few months ago I added an Erlang version. It’s great to have a JavaScript version now too.

Another Great QCon

November 22nd, 2008  |  Published in conferences, REST  |  Bookmark on Pinboard.in

Just getting ready to fly home from QCon San Francisco. Not surprisingly, it was another great conference, and the organizers told me that attendance was up about 30% over last year. Having a well organized and well executed conference with a large number of great speakers tends to have that effect.

Jim Webber put together and ran the REST track, and it was one of the best tracks I’ve ever been a part of. Mark Nottingham is extremely knowledgeable on the REST and HTTP fronts, so he gave a very informative talk on HTTP and the work of the HTTPbis group. Ian Robinson and Stu Charlton both spoke on using REST in the enterprise (it’s coming, like it or not). Leonard Richardson talked about how to judge the quality of RESTful services, but I missed most of his talk because I went out to stretch my legs and couldn’t get back in because the room was so packed! I spoke about my work with REST, Erlang, and Yaws. You can get all the slide sets for this track from the QCon site.

Got to meet a few people in person for the first time, such as Leonard, and also Tim Bray (who asked great questions during my talk, thanks Tim), and Michael Nygard, who is as bright and articulate in person as he is in his amazingly wonderful book (if you haven’t read it, do yourself a favor and put it on your holiday wish list). I also briefly met Dave Pollak who gave a great talk on Scala and Lift in Erik Meijer’s “Functional and Concurrent Programming Languages Applied” track. I found it interesting that in Lift he uses some of the same request dispatching techniques I use in my work with Yaws, even though he’s writing in Scala and I in Erlang. Functional languages rule.

Speaking of Erlang, Francesco Cesarini was there, also speaking in Erik’s track. He talked about Erlang concurrency and the continued development of Erlang’s SMP capabilities. Jan Lehnardt gave a couple of CouchDB talks, which seems to just keep garnering more and more interest, and rightfully so. Dennis Byrne gave a talk on Erlang and DSLs — I unfortunately missed it but knowing Dennis I’m sure it was thought-provoking and worthwhile.

It was also fun getting to see and hang out with Jay Fields and Glenn Vanderburg again. Both are extremely sharp.

Thanks again to the QCon organizers for another wonderful conference, and I’m already looking forward to QCon London next March.

RESTful Web Services Development Checklist

November 1st, 2008  |  Published in column, coupling, design, distributed systems, HTTP, REST, services  |  Bookmark on Pinboard.in

My Nov./Dec. Internet Computing column is now available. It’s entitled RESTful Web Services Development Checklist and as its name implies, it covers some of the primary areas developers need to focus on to write good RESTful web services. These areas are:

  • Resources and their URIs
  • Applications and Hypermedia
  • Representations and Media Types
  • Methods
  • Conditional GET

Regarding the “Applications and Hypermedia” area, I feel Roy Fielding’s pain that many efforts labeled as being RESTful seem to completely ignore the hypermedia constraint. I believe many developers tend to miss this constraint because they’re so used to using libraries and frameworks that offer lots of entry points, and having knowledge of those entry points in the client normally isn’t that bad since the client and library/framework are tightly coupled into the same address space anyway. In a distributed system, though, this definitely does not hold true; when the client knows a bunch of entry points into the service, it ties the client to that service and inhibits their independent evolution.

Anyway, please read the column and let me know what you think, and thanks again to Stefan Tilkov for his helpful review of the draft.

Coincidentally I also feel Roy’s pain when it comes to writing about REST. He states:

I don’t try to tell them exactly what to do because, quite frankly, I don’t have anywhere near enough knowledge of their specific context to make such a decision.

So, when you find it hard to understand what I have written, please don’t think of it as talking above your head or just too philosophical to be worth your time. I am writing this way because I think the subject deserves a particular form of precision. Instead, take the time to look up the terms. Think of it as an opportunity to learn something new, not because I said so, but because it will do you some personal good to better understand the depth of our field.

Exactly.

Obviously, Roy is the ultimate REST authority, given that he defined it, so I’m not at all claiming to be anywhere near as authoritative about it as he is, yet I’ve also experienced what he says above. For example, consider this informal review of my columns I received a few months ago in a comment on someone else’s blog:

The articles of yours that I’ve read are…amorphous to me. They speak in generalities. I haven’t read an article where you sit down and write the same service using both REST and RPC and compare the two. When you speak in generalities, we can’t objectively evaluate any of the specific trade-offs between approaches… Arguments that happen at too abstract a level can’t go anywhere, because our positions aren’t specific enough for anyone to evaluate anybody else’s claims.

In other words, “since your columns don’t do my thinking and experimentation for me, they’re useless to me.” Hmm. Maybe I’m just old school, but I’d much rather understand mathematics than require someone to hold my hand while I blindly punch buttons on a calculator. In other words, as the old proverb goes, I’d much rather try to teach you to fish so you can feed yourself. As I state in this new column:

Whether developers of RESTful HTTP-based services write their code in IDEs or with simple text editors, and regardless of which programming languages they use, they must understand REST and HTTP fundamentals to succeed.

Mimeparse in Erlang

September 23rd, 2008  |  Published in code, erlang, HTTP, python, REST, Ruby, services  |  Bookmark on Pinboard.in

If you’re writing RESTful web services, you need to be able to parse HTTP Accept and Content-type headers. The Accept header tells you what media types the client can handle, and Content-type tells you what the client is sending when it invokes PUT or POST.

Several years ago Joe Gregorio wrote a really nice article explaining how to properly handle such parsing, and he implemented his ideas in the form of the mimeparse Python module. Later, others added Ruby and PHP versions.

In my Erlang web services work I’ve been doing just enough to parse my Accept headers, knowing full well my approach had holes in it and would eventually need to be done right. When I recently stumbled on Joe’s article and code, I decided to port it to Erlang and use it. Joe’s code is very clean and has accompanying unit tests, so the port was pretty easy. However, in the process of plugging it into my system I found a reasonably common case where the best_match function would return a wildcard match in preference to an exact match, so I added unit tests for that case and repaired the problem for all four languages.

I also found that Java’s URLConnection class, or maybe it’s HttpURLConnection, sends a plain “*” as a wildcard MIME type, which I don’t believe is legal (please correct me if I’m wrong), but since I figure there’s probably more than a few clients out there based on that code, I modified the four mimeparse implementations to handle that as well, treating it as “*/*”.

All four implementations are available from the mimeparse project home page.

The Technology Adoption Side of RPC and REST

September 3rd, 2008  |  Published in column, enterprise, innovation, REST, RPC, technology adoption  |  Bookmark on Pinboard.in

My latest Internet Computing column has been available since last Friday. It’s entitled “RPC and REST: Dilemma, Disruption, and Displacement” (PDF, HTML) and like my previous 2008 columns, it explores another angle of the “RPC vs. REST” debate.

Since previous columns have covered many of the technical angles, this time I present the debate from the technology adoption angle. As the abstract for the column says, many technologists tend to treat such debates as if they’re purely technical, but of course they’re never that black-and-white. What’s often behind some of the raging “technical” debates we’ve all seen or experienced is simply the difference between the arguing parties in their relative positions along the Technology Adoption Lifecycle curve. Nobody would be surprised at a disagreement over technology between someone classified as an early adopter or visionary (from the far left of the curve) and someone classified as a technology skeptic (from the far right), yet we always seem surprised when two people whose preferences aren’t too far apart on the curve — from the opposite edges of the mainstream band in the middle of the bell curve, for example — don’t see eye to eye, despite the fact that this sort of scenario is quite common. Even small differences in goals for adopted technologies and desired risk/reward trade-offs, along with the inevitable hidden and unstated assumptions resulting from such factors, can cause vigorous debate about what technology or approach is best for a given situation.

When it comes to published explanations of how innovation works and how technologies move along the adoption curve, my favorite author by far is Clayton Christensen. IMO all developers should study and learn from his books, specifically The Innovator’s Dilemma, The Innovator’s Solution, and Seeing What’s Next. All are amazingly insightful works that will open your eyes to how real-life markets react to technological change and advancement.

In this column I try to view and classify the “RPC vs. REST” debate based on Christensen’s theories about innovation and technology adoption. I hope you find it interesting, and as always, I welcome all constructive comments.