JSON Sucks

“Oh, Hooray!” I hear you all shout. “I’ve waited so long to hear Jerry to rant once more about esoteric technical standards!” I’m back, baby! You don’t have to thank me, it’s what I do. (occasionally)

If perhaps you were not looking forward to a technical rant, may I suggest you spend a little time at We Rate Dogs instead. They are awesome, and work hard to make life better for people and animals.

Back to the rant…

How to move information between systems that know nothing about each other is a challenge. The two sides have to agree on how that data is reduced to ones and zeroes to be pumped over a wire, and how the ones and zeroes are interpreted on the other end. In the biz, we call this a transport. It’s a way to move information from one place to another. As long as both sides understand the transport, all is well.

But “all is well” is relative. Some transports are more flexible and precise (and simply faster to encode and decode) than others.

The first serious contender in this space was XML. XML is really complicated, but allows sophisticated layering of the rules for encoding and decoding. But for everyday shifting of data XML is overkill. When you just want to move information between friends, XML imposes a lot of unnecessary overhead. JSON provided a simpler answer.

JSON exists because every web browser supports JavaScript, so a JavaScript-compatible transport made perfect sense. The “JS” in JSON is “JavaScript”.

When the kids were inventing JSON, they could have defined ways to pass arbitrary data as bytes, but they did not. They wanted a simple transport that Javascript could easily decode. JavaScript can’t handle really big numbers, so there was no reason to have JSON solve that. The transport was designed for a very narrow problem: getting data to browser apps written in JavaScript. The JSON builders could have looked past the immediate problem to make a more general transport, but that would have encumbered their own, very focussed standard.

But, like so many standards to fix a specific problem, that standard was embraced unquestioningly as a solution for many cases it was never designed for.

This is why web app development is twenty years behind modern software practices. There is a problem, and the first shitty solution to come along is embraced, and the whole “this is how things work” is promoted so loudly that any better solution is lost in the noise.

But JSON can’t handle really big numbers. JSON can’t handle image data in a compact format. JSON has to turn UUIDs from 16 bytes to a huge-ass string. JSON, actually, is not very good. And there are MUCH faster and more flexible ways to send your info over the wire. JSON is only useful for passing data to and from a browser.

And yet!

You know what makes no sense at all? Using JSON to pass data between cloud services. If there is not a browser on either end of the pipe, JSON is the wrong answer. And yet today I’m dealing with GraphQL, which could have chosen any transport at all to talk to its various parts, and chose JSON.

This is the lingering malignancy of past bad decisions. It never even occurred to the people who made GraphQL to use any transport other than JSON. They knew its flaws, but never considered an alternative. In fact, they never considered that there might BE alternatives; they wrote their specification directly around JSON.

So today I am trying to make my services become subgraphs, and I am grinding my teeth as my tight, well-considered data types are stretched and warped to fit JSON. Bigger, slower, and not type-safe. No modern system should use JSON. But here we are.

3

Ferrari’s New Electric is Too Subtle for its Own Good

Ferrari has entered the electric market. It isn’t going so well. This car was designed by Jony Ive, the guy who designed iPhones and iMacs and even Apple’s new corporate headquarters.

When you read about the design, about the craftily integrated front and rear wings, about the airflow under the car, you appreciate the attention to every tiny detail that went into the design. But there’s this:

The wind tunnel has its way. If you look you can see the gap in front of the windscreen that air passes through underneath the front wing. The construct on the rear is similar but subtler. The elegant integration of aerodynamics is artistically unimpeachable. But, this is a Ferrari. We are not here for subtlety or even elegance (Dino excluded). This car is ridiculously fast, but not as fast as other electric supercars. Notably this is the first Ferrari to seat five.

The super-low-profile tires you see above are part of the answer to the biggest question for electric performance cars: How do you make a car with a thousand pounds of batteries turn? Tesla, in this space, is including on their upcoming supercar a SpaceX version with actual fucking (electrically powered) rockets to improve cornering. They will not make a measurable difference.

Honestly, were I the boss of a supercar company, I would certainly embrace aerodynamics in my electric entry, but I would embrace my heritage more, and put fat soft tires on the road and have the four wheel motors tuned to distribute the thrust for cornering (maybe the Ferrari does that already, but I haven’t heard about it). While I find many supercars absurdly macho — angular and fiddly — there is a middle ground out there.

Ferrari fans are not terribly impressed, and I believe it goes beyond performance numbers or styling that goes out of its way to be like a jelly bean. There’s something a roaring V12 engine directly behind your head can do that no electric motor will duplicate. It’s loud! Loud in the way an arena-rock concert is loud, invigorating and unnerving and isolating.

And for the male Ferrari drivers (which is almost all of them), it makes their testicles vibrate. And that is what they are paying the big bucks for.

1