5 ms·
My go-to example for high vs. low compositionality is JSON vs. HTTP. JSON has high compositionality - if you want to replace an atomic value with a more complex
by olooney 8y ago
My go-to example for high vs. low compositionality is JSON vs. HTTP. JSON has high compositionality - if you want to replace an atomic value with a more complex value, you can use JSON itself to structure the new complex value. Whereas HTTP Headers were originally defined as key-value pairs, one per line, and had to introduce new syntax in an ad-hoc fashion. That's why User-Agent uses semicolon, which Accept-Encoding uses comma, Set-Cookie often uses Base64 encoding, normal form submits use URL encoding, but file uploads use the multipart form encoding which uses MIME boundaries. Each time the same problem came up (encoding multiple values, or values which may include delimiters from one level up in some kind of structured way) a new solution is invented. A natural language analogy to the HTTP approach would be a grammar rule saying, "when you want to use a subclause or a noun phrase, switch from English to Japanese." So you would say:
The woman is pretty.
But if you wanted to nest the statment "pretty woman" you would "encode" it by switching to Japanese like so:
The kirei onna is nice.
This example is absurd, but how is it any different than HTTP's ad-hoc approach to nesting, really? The HTTP approach quickly bogs down, while formats with high compositionality like JSON or YAML can be extended even to very complex structures; for example, the docker-compose.yml file or package.json.
- smadge 8y agoI do see your point, but you are comparing two very different things. HTTP is a protocol, JSON is a data format. In a lot of ways HTTP is highly composable because along with hypertext media types like HTML or JSON-LD it allows for composition of documents and applications across hosts and networks into the World Wide Web. Vanilla JSON can’t do this without a hypermedia extension like JSON-LD.