Protocols vs Styles

by Subbu Allamaraju on April 28, 2012 · 48 comments

My RESTful Web Services Cookbook has been out for nearly 26 months. From Feb 2010 till the end of 2011, O’Reilly sold 13,052 copies (both print and eBook format combined, per the royalty statements received to date) of this book. Given that O’Reilly’s eBooks are DRM free, I would like to think that several thousands more copies were downloaded for free on torrent sites, but there is no way to know.

Writing this book was a painful exercise. I spent most of 2009 writing the drafts – at that time Yahoo allowed me to spend about 20% of my time for nearly 4 months to write the first draft (for which they own the copyright of the book). It was painful because REST was about style. Not having seen all aspects of the style work in reality, I was not fully convinced about parts of the style. Separating style from protocols was a time consuming yet learning exercise. How could I say that following such and such Roy Fielding’s constraint leads to evolvability without dissecting evolvability into concrete details? The last thing I wanted was to write a book that paints a nice picture with the benefits one would get out of REST without discussing the specifics. I wanted to avoid handwaving at all cost.

In these two years, I changed quite a bit.

  • I no longer actively engage myself in discussions about REST.
  • I unsubscribed out of rest-discuss in 2011.
  • I don’t even subscribe to Roy’s idea that REST APIs must be hypertext-driven or that “A REST API should spend almost all of its descriptive effort in defining the media types”.

What I learned in these two years were the following:

  • Don’t confuse styles with protocols.
  • Understand what you are going to interoperate with and make tradeoffs as necessary.
  • Interoperating between style deviations is more important than arguing for style adherence.
  • Interoperability is partly a protocol problem and partly a software problem.

Architecture styles are guides, but protocols specify rules. Roy’s REST codifies (to some extent reverse-engineeres) the Web into a set of constraints. Constaints are what they are – guides sans context. They are subject to tradeoffs. They postulate benefits when applied. But protocols are different. They set ground rules for different systems to work together. Just like you don’t start driving on the left side of the road (in the US), you don’t break TCP or HTTP’s messaging formats. When you break such protocols, you prevent networked systems from working together.

But we tend to mistake the style (i.e, REST) for the protocols. I made that mistake several times (shame on me!) in the past, and I still see it being made. I took care to avoid this while writing the book, but I may not have succeeded fully. Strong belief in a style often leads to zealotry. This is no different from the zealotry we see in socio-political debates.

Yet not all Protocols are the same. I tend to view protocols making up a pyramid. Where a protocol stays in this pyramid shows how widely it helps interoperability.

    /\
   /  \
  /    \
 /______\

Towards the bottom are protocols that strive for the widest range of interoperability possible. TCP is an example. HTTP is another example. As you go up the pyramid, the amount of relevance and influence a protocol carries becomes narower. For instance, I would keep RFC 2616 towards the bottom of the pyramid, but an RFC like 5023 (AtomPub) towards the top. AtomPub’s reign of influence was limited then and is even now. I would similarly place a media type like application/json towards the bottom, and a type like application/my-grand-fathers-facebook-profile+json at the top. A perspective of where a protocol belongs in this pyramid certainly helps ration energy.

So, would I write this book differently now? I certainly would.

  • I would change the title to something along the lines of “Recipes to Build Client Server Apps Using Web Protocols”, though the editor might ask me to change to include some current trending words.
  • I would emphasize even more on protocols.
  • I would cut down or clearly demarcate the parts of the book that suggested design styles (such as designing formats).
  • I would spend a big chunk on how to interopere without necessarily agreeing on the style.

If you’ve read my book, and built some interoperable Web based systems, you might come to the same conclusion as I did. If that happens, I count my book as a success.

{ 47 comments… read them below or add one }

(@rbergman) (@rbergman) April 28, 2012 at 11:07 pm

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

Peter Keane April 28, 2012 at 11:20 pm

Excellent & thought-provoking posting. I stopped reading rest-discuss about the same time. I’m not sure exactly what happened, whether “religious wrangling” killed REST or whether REST “won” and the wranglings became irrelevant. What I do think in retrospect is this: HTTP was & is an unusually “above the surface” protocol. I can happily build networked systems and know little of how the underlying protocols such as TCP work — as long as I know how to open or read from a socket in my langauge of choice, I’m OK. But HTTP is highly exposed, even for a beginner front-end HTML coder (E.g. POST vs GET on an HTML form). But a mistake was made in that it was treated for a long time as a transport protocol that was better hidden away underneath the “convenience” of first generation web application frameworks. The whole REST movement was largely a (critically important) move to “surface” HTTP and start seeing it as the application protocol that it is. I think that’s where the “design” piece begins — once you embrace the basic pieces of HTTP/REST (thing have names — URIs, we can peform standard methods on those — GET/PUT/POST/DELETE, and hypermedia — links/forms, etc. drives states) there’s plenty more to be figured out (i.e. designed). But I’d contend that accepting/understanding those basics is still a huge win. And concrete examples of designs that take those basics as a foundation are very useful. FWIW, that’s exactly why your RESTful Web Services Cookbook is still my top recommendation for new web application developers.

Reply

Pedro J. Molina (@pmolinam) April 29, 2012 at 12:05 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

graste (@mivesto) April 29, 2012 at 1:08 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

Denisse Calderon (@dpcal) April 29, 2012 at 2:08 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

(@RubenVerborgh) (@RubenVerborgh) April 29, 2012 at 3:11 am

@sallamar explains how he changed and no longer subscribes to the idea that “REST APIs must be hypertext-driven”. – http://t.co/R8ApdAkd

Reply

(@c4milo) (@c4milo) April 29, 2012 at 4:07 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

Rogers D. Stephens (@redblue36) April 29, 2012 at 6:06 am

Protocols vs Styles http://t.co/clLGYSxP #soa #rest #apparch

Reply

(@olympum) (@olympum) April 29, 2012 at 7:02 am

Strong belief in a style often leads to zealotry confusing it with the protocol. Thought provoking read. http://t.co/j3ZOVk0d

Reply

Wolfgang Frank (@wolfgangfrank) April 29, 2012 at 8:27 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

e_quilibre (@e_quilibre) April 29, 2012 at 10:08 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

Ian Bashford (@eanu) April 29, 2012 at 11:38 am

@johnbassil interesting… “@sallamar: On the blog – “Protocols vs Styles” – http://t.co/j2YC8gKE

Reply

Per Wramdemark (@perw) April 29, 2012 at 1:12 pm

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

Jonathan Halterman (@jhalt) April 29, 2012 at 9:32 pm

Protocols vs Styles http://t.co/hls9ydhh

Reply

Nell Gawor (@ngawor) April 30, 2012 at 4:54 am

RT @snoopdave: “I don’t even subscribe to Roy’s idea that REST APIs must be hypertext-driven” | Protocols vs Styles | http://t.co/9zrZVBbY

Reply

Colin Jack (@colin_jack) April 30, 2012 at 8:04 am

Protocols vs. Styles: http://t.co/OLxp1KSn

Reply

Ollie Riches (@AwkwardCoder) April 30, 2012 at 8:38 am

RT @colin_jack: Protocols vs. Styles: http://t.co/OLxp1KSn

Reply

Peter Cnudde (@pcnudde) April 30, 2012 at 11:26 am

RT @olympum: Strong belief in a style often leads to zealotry confusing it with the protocol. Thought provoking read. http://t.co/j3ZOVk0d

Reply

Christian Fauré (@ChristianFaure) April 30, 2012 at 12:47 pm

Protocols vs Styles http://t.co/yNpjv71u

Reply

Clochix (@clochix) April 30, 2012 at 2:48 pm

Ne pas confondre style d’architecture, pe REST, et protocoles http://t.co/Tc7ZI0Yq /via @ChristianFaure

Reply

(@jasper_07) (@jasper_07) May 1, 2012 at 3:04 am

Protocols vs Styles http://t.co/66CelZno great read

Reply

Andreas Huppert (@andreas_huppert) May 1, 2012 at 4:24 pm

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

(@pchapuis) (@pchapuis) May 2, 2012 at 5:41 am

What would @sallamar do differently if he wrote the “RESTful Web Services Cookbook” now? http://t.co/wGAO19UU #apidesign

Reply

Tatu Saloranta (@cowtowncoder) May 2, 2012 at 9:05 pm

RT @sallamar: If you’ve read my http://t.co/dIcUjkcM and come to the same conclusion as I did in http://t.co/DjzLxtif – thanks and mission accomplished.

Reply

Alexey Prohorenko (@alexeypro) May 2, 2012 at 9:21 pm

Protocols vs Styles http://t.co/ImK9iNQ9 #FB

Reply

(@Kingwulf) (@Kingwulf) May 2, 2012 at 10:53 pm

RT @sallamar: If you’ve read my http://t.co/dIcUjkcM and come to the same conclusion as I did in http://t.co/DjzLxtif – thanks and mission accomplished.

Reply

Sergio Bossa (@sbtourist) May 4, 2012 at 2:27 am

Honest and worthy post by @sallamar about REST and the perils of blindly following constraints and guidelines: http://t.co/8GxzkLlF

Reply

Nexse SWAT Team (@NexseSwatTeam) May 5, 2012 at 8:16 am

Protocols vs Styles http://t.co/aSwqoKOu #rest

Reply

Sam Schenkman-Moore (@samsm) May 6, 2012 at 8:55 am

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Matt Bowcock (@mbowcock) May 6, 2012 at 10:02 am

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Onorio Catenacci (@Onor_io) May 6, 2012 at 1:12 pm

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Ben Longden (@blongden) May 6, 2012 at 1:47 pm

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

David Roberts (@davidroberts63) May 6, 2012 at 6:55 pm

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Matt Jackson (@mwjacks0n) May 7, 2012 at 3:03 am

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Hammad Rajjoub (@HammadRajjoub) May 7, 2012 at 3:21 am

RT @Meligy: Protocols vs Styles: What the author of “RESTful Web Services Cookbook” believed changed since he wrote it! http://t.co/axpfC3e3

Reply

Jardel Weyrich (@jweyrich) May 7, 2012 at 5:33 am

RT @hypermediaapis: In which Subbu (Author of the RESTful web services cookbook) basically renounces REST: http://t.co/UK2AAIMq

Reply

Andreas Arnold (@codepoet_ch) May 8, 2012 at 8:09 am

So, REST is over? RT @hypermediaapis: In which Subbu (Author of RESTful web services cookbook) basically renounces REST http://t.co/U65cPcOA

Reply

David Lojudice S. (@dalssoft) May 8, 2012 at 9:58 am

RT @sallamar: On the blog – “Protocols vs Styles” – http://t.co/DjzLxtif #yam

Reply

(@nikhilvora) (@nikhilvora) May 21, 2012 at 1:25 pm

Protocols vs Styles http://t.co/57wNI3fO

Reply

R.Sriram May 25, 2012 at 4:16 am

Is there any reason on why you dont subscribe to the idea that “REST api must be Hyperdriven”. I mean any practical difficulties that you had faced when interoperating with other systems.

Reply

Subbu Allamaraju May 28, 2012 at 4:47 pm

I don’t subscribe to the “must” part. A style is subject to tradeoffs. There are no “musts”.

Reply

jay August 13, 2012 at 7:44 am

Subbu, I see the “must” as giving a “definition” here. If REST is, by definition, to use hypermedia, then not using hypermedia is not REST. If the REST style emphasizes focus on media types, then systems built with little or no thought around media types are not RESTful.
Do you mean that you no more subscribe to the view that all distributed systems must be hypertext driven? That makes sense. But the common problem is that people just don’t understand what they mean when they describe their systems as RESTful, and there, Roy’s rant is justifiable.

Reply

Subbu Allamaraju August 13, 2012 at 9:07 am

Jay – I don’t see strong reasons for all distributed systems to be hypertext-driven. In the overall scheme of things, the value hypertext could add to distributed systems is a tiny fraction. Folks are unfortunately confusing distributed systems with the Web.

Reply

jay August 13, 2012 at 11:21 am

I agree. Hypertext is not the only design style. There are many, and you make tradeoffs. What you end up with is often a hybrid style. It is ok if I choose not to use hypertext, but if I build a system with no hypermedia and call it hypertext-driven, then I only am confused.

Great post clarifying the confusion between Protocol and Styles. Look forward to reading more like this from you.

Wen-Tien Chang (@ihower) September 26, 2012 at 2:08 am

Protocols 和 Styles 要分清楚,想不到 RESTful Web Services Cookbook 這本書的作者,在出版兩年之後,竟然這樣寫了一篇自白…
http://t.co/1lfRa6n9

Reply

MC.Spring (@mcspring) September 26, 2012 at 6:32 pm

http://t.co/ct7ssSRu 从《RESTful Web Services Cookbook》作者文章中得知:用1年多时间写成的书,最终只卖出13052本(不知是否仅限于US?),sigh~

Reply

tka.lu (@tkalu) October 23, 2012 at 6:04 am

Leave a Comment

Previous post:

Next post: