Thrift, a quick detour

For the uninitiated Thrift is an interface definition language, an RPC mechanism, and a family of wire protocols and serialization encodings. I won’t rehash all of the debate but I will offer a little bit of personal opinion that is informed heavily by my pre-Facebook life contrasted with life at Facebook. Before that I accept a few things as a priori true at any scale worth talking about (i.e. more than 1 of any of the following: developer, language, client, computer, server or use case.) First is that strong typing is not just good but virtually essential to escape chaos, that composition is better than inheritance, that explicit is better than implicit, and that once you deploy something you expect to be able to iterate on it without breaking all of your clients.

Thrift is a highly imperfect solution to a problem that a surprisingly large number of tech stacks never figure out is even a problem. Steve Yegge put it incredibly well in a legendary rant at Google comparing them to his prior home, Amazon. While he is comparing one global scale company to another, the points really do scale all the way down to small shops, but also to the supposed dinosaur enterprise environments. In the startup scene it has come to be an accepted writ of fact that something resembling a micro services model is the Right Way(tm) to architect scalable services, but the rest of the world is still, understandably, wrestling with whether this is true for their insurance business, or shipping company, or pencil manufacturing business. My personal belief is that it does, in broad strokes and that there is a lot of pent up potential locked behind proprietary systems in a lot of businesses.

When you can quickly and easily get a client for a service, know what functions it exposes and what datatypes you will get back it transforms how you can develop software. I particularly like the way that with code gen for generic clients meshes with a well defined wire format that allows for bespoke implementations if the situation calls for it with a lot of shades of customization and tuning possible in between. One of the themes in tech the last few years has been reducing friction and tearing down walls. Having a uniform, comprehensible and pretty darn functional services/rpc layer is a cornerstone for enabling a culture that doesn’t just not inhibit collaboration but actively empowers and promotes it.

I feel that Thrift unintentionally hits a real sweet spot by offering tools to define not just public API but also data structures and exceptions with a compositional style. This means that a Thrift IDL spec can do a lot of the important work that might once have invoked the dreaded UML diagram. Whether UML really is an AbstractProblemFactoryBuilder or not, simpler tends to be better and Thrift is definitely a lot simpler and more approachable. Its also worth noting that you do not have to use every struct in your service interface, it is both reasonable and easily possible to use it to define all of your important objects since you can pretty easily ensure you have efficient implementations. Its not something you’re likely to find a lot of call for, but when you want to do it having one tool to define it all is nice.