←back to thread

Fixing JSON

(www.tbray.org)
139 points robin_reala | 2 comments | | HN request time: 0.465s | source
Show context
niftich ◴[] No.12328088[source]
I know this is from Tim Bray, one of the primary authors and/or maintainers of XML, RDF, Atom, and JSON, but while I too find some annoyances with JSON, I accept them because:

- JSON was never designed to be hand-editable. It's a lucky accident that it's more palatable to edit than XML, but there are other formats like YAML, TOML, and even .ini that fulfill that purpose.

- While JSON was originally envisioned as a subset of Javascript and intended to be materializable by JS eval(), this very quickly turned out to be a bad idea. Once we all switched to using parsers, there is no more compelling need to remain compatible with Javascript, other than human recognizability of syntax, and, y'know, compatibility with 'old' JSON; and

- JSON's greatest strength is that it has such a good impedance match to native 'abstract' data structures supported in just about every contemporary programming language: strings, numbers, lists, maps. When people say 'simple', I don't disagree, but I'm convinced they're actually referring to this feature. Adding additional types -- yes, even timestamps -- would break this property, as datetime handling in most languages leaves a lot to be desired.

replies(1): >>12328162 #
joshstrange ◴[] No.12328162[source]
The first language that comes to mind when I hear "datetime handling in most languages leaves a lot to be desired" is, slightly ironic considering JSON's origins, javascript. If you ever touch a date in JS you HAVE to pull in something like moment, full stop. JS Date is a steaming pile of shit.
replies(2): >>12328357 #>>12328884 #
1. robocat ◴[] No.12328884[source]
I thought that the Date API was closely copied from Java? I do agree it is nasty to use.

Tim's ideas are just dangerous - they ruin compatibility for questionable gains. Why not just invent his own standard and call it something else, rather then trying to bust what we have already.

replies(1): >>12336023 #
2. joshstrange ◴[] No.12336023[source]
If so when it was copied Java had shit DT handling. The lack of a concept of timezones and auto-converting a UTC time to local time make life a living hell as soon as your code has to span more than 1 TZ.