Sunday, October 11, 2015

Giving it a REST


I don’t remember deciding that I was a fan of REST APIs, but I found myself in that position for a lot of years. I was really only getting to the point as a developer that I was even thinking about APIs around the time when REST was already on the scene, and especially was getting more popular among the Python community and among the Web developer communities, the two places I drew most of my social influence from in the are of programming.

SOAP was not a disaster that I had really much experience in, save for a couple very brief encounters. One of my first small programming contracts was actually wrapping a SOAP service into a RESTful endpoint. The main business model of my client was reselling another service because developers would prefer to use this improved API that much more that the small premium would be worth it. I was young and impressionable and looking back, I don’t know if the SOAP API I had to work with directly for this job was actually as bad as it was made out to be or if it was me picking up the tone of the job. And, I think, interacting with SOAP services probably is different in different languages, and maybe doing it in Python from scratch and entirely by hand was definitely more painful than some more strict languages with heavier SOAP tooling in their ecosystems.

So these ideas I’ve held for so long about how great REST is and how awful SOAP was are not ideas I can really trace back to experience or education. They’re things that I largely picked up socially. SOAP was always the poster child for the wider idea of RPC (Remote Procedure Call) APIs, but the negative tone was definitely equally applied to any similar system (which was almost always XML based, of course).

A tale I’ve heard about an experiment involving social pressure and monkeys goes like this. The scientists had a cage with a bunch of monkeys and they had a ladder in the center that let them to some treat up at the top. Immediately the monkeys tried to get there, but when they would try someone would spray them with a hose and get them off the ladder and repeat this until none of the monkeys would even try. When all of the monkeys had learned this lesson, they removed one monkey and replaced him with a new monkey, who didn’t know about the ladder and tried to get the treat. The hose was used again, and all the monkeys were punished. The monkeys were replaced like this, one by one, until they learned to self police and stop any new monkey from trying to climb the ladder. The hose wasn’t even needed. Eventually, none of the monkeys in the cage had ever even seen the hose, but they all knew what to do when someone climbed the ladder.

Some times I feel like we’re all the monkeys and RPC is that treat at the top of the ladder. And maybe, in this scenario, SOAP is the actually ladder? The point is, I feel like we all avoid this thing we don’t really understand and we do so based on the experience of others we’ve gleaned from, about something we don’t actually understand beyond the surface fear of.

At this point I feel like I don’t know what I missed or left behind, and I’m not just abandoning REST (nor could I, as it is inescapable in the current landscape) but I want to recognize that learning more about alternatives is something I’d like to do. I know SOAP enough to know I don’t want to get to know it better, but I also feel like tooling is a missing piece here. I want to understand, with the right tooling in place, how much less might I care about the protocol being used and what else might I value in that protocol?

No comments:

I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive