Hacker News new | ask | show | jobs
by benjaminbrodie 2527 days ago
It's a good question and even if the text approach is superior we need a better reason than typically given.

I mean think about it. Suppose you want to communicate a JSON object to another programmer.

You can say: "the object consists of three key value pairs, the first key is named ... and its value is ..., the second ..."

Or you can say: "the object is that which you get from parsing the string that spells thus: curly bracket, space, double quote, ..."

Of course you'd prefer the former approach! Why then when we wish to communicate to a computer the same object, we adopt the "spelling approach"?

2 comments

Because we're not verbally dictating instructions to the computer, we're writing them. Say you want to communicate that JSON object via chat to that programmer, how is this:

{"x":"bar", "y":"foo", "z":"foobar"}

Not the clearest way of communicating it?

For similar reasons, mathematical notation is used instead of explaining equations in plain English, despite mathematicians' audience not being computers.

Symbolic notation has value: while it takes more initial effort to understand, once you have grasped it, the result is far more concise, unambiguous and generalizable.

Whatever you say must needs be parsed. And humans can parse the curly-brace style about as easily as any other semantic representation.

The advantage is transparency. I'm actually not sure if the tradeoff is worth it, if symbolic code manipulation would be better, but code as we've written it is no harder for humans to parse than would be a symbolic representation of the same. It already is a symbolic representation of itself, because humans don't see curly brace, double quote, key; humans see things in groups and clumps. Just as when you read these words I'm typing you don't see period, double space, J, u; you see 'clumps. Just'. However, what you see on your screen is exactly the file that's stored on the disc, the bytestream read by your texteditor, the bytestream read by your compiler. And that's worth something.