mashraqi

> david-heinemeir-hansson

[ This is my personal blog so all opinions expressed here are mine. I am a product, scalability, operations and monetization advisor and currently employed as Director of Business Operations & Technical Strategy for a top 50 website that delivers billions of page views per month. I was a keynote panelist for Scaling Up or Out keynote at MySQL Conference and speak regularly at conferences and user groups. ]
Farhan "Frank" Mashraqi

Wednesday, September 17, 2008

Go REST with Rails

David Heinemeir Hansson is speaking on Go REST with Rails. David wasn't interested in programming but more interested in programs. They decided that at Basecamp they should have APIs. In 2004, not a whole lot of people knew about REST. Flickr API was very unsatisfying at that time. He didn't have an approach that they could hold on to encapsulate development. REST is based on HTTP. Problem with HTTP is that it is like Ogre and Ogre have layers (so do Onions). When he was doing Basecamp he didn't want to worry about GET or POST.

Using REST is like re-discovering the HTTP protocol. Most developers overlook the depth of protocol. REST has very closely assigned relationship with HTTP. REST is like blue-cheese in the sense that it is very much acquired taste. The first time you try it, it seems disgusting. Once you get hooked on it, it is really tasty. REST is a really well thought out approach. That's why there is a very harsh barrier to entry.

What are the barriers? Foundation of REST comes from a guy named Roy Fielding. In chapter 5 of his 2000 dissertation, he introduces REST. He says

"This chapter introduces and elaborates the Representational State Transfer (REST) architectural style for distributed hypermedia systems, describing the software engineering principles guiding REST and the interaction constraints chosen to retain those principles, while contrasting them to the constraints of other architectural styles."

He is talking about WS-*.

REST has infiltrated Rails in the past few years. Creating a REST application is as simple as creating a Rails application. Next he guides people through it. Multiple representational ability of Rails reall helps as you shouldn't need to re-do the work just in order to have another representation.

In PostsController you can do the following to add more representations:

respond_to do |format|
format.json {render :json => @post}
end

ActiveResource is a convention that builds on same principles as ActiveRecord. Rails is all about Convention over Configuration. Rails allows you to spot natural borders.

David is a great speaker and it was a pleasure to sit in his session finally. I do however wish he'd talked more about scaling REST services, but may be the audience wasn't right.

Labels: , , , ,

  • View Farhan 'Frank' Mashraqi's profile on LinkedIn
  • Structure 08
  • Graphing Social Patterns - East 2008
  • Velocity Conference
    follow me on Twitter

    © 2006 The Mashraqi's.