4 ms·
You can blame Crockford for that: [1] TLDR: Basically, in a typical Crockford move, he saw people were using them in a specific way he did not like (to store p
by rootlocus 9y ago
You can blame Crockford for that: [1]
TLDR: Basically, in a typical Crockford move, he saw people were using them in a specific way he did not like (to store parsing parameters), so he removed them entirely. I say "typical Crockford" because some of his JS linting rules are gratuitous overkill in my opinion. He also suggests that if you want comments, you should pipe the config file through a minifier that removes them before parsing.
Doesn't seem like that much of a good reason to me, but whatever.
1. https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaG...
- seanwilson 9y agoYeah...that's frustrating. For a Chrome Extension manifest JSON file I was recently editing, you have to enter a description field that I found out is limited to around 100 characters after a failed upload. I wanted to add a comment above this field so myself and anyone else editing the file was aware of this in the future (a good use of comments in my opinion). I'm not going go through the hassle of a build step to do this. Programming languages allow comments for a reason and I don't see what's so different about JSON.
- DaiPlusPlus 9y agoIf the consuming program allows it, you can fake a comment by storing it as a JSON property value: { "myComment": "This is a comment!", "realValue": 1 }
- seanwilson 9y agoThat's what I did actually. I don't like it though. A comment is really saying "this is a note for the reader that isn't used at runtime". Putting a comment in as a value goes against that and it uses up memory when the file is read in.
- rpdillon 9y agoOn the flip side, I've always found it useful when debugging at a REPL to be able to read various kinds of metadata about objects, including documentation. Clojure is one example of this, but I wouldn't mind seeing it elsewhere as well. https://clojure.org/reference/metadata https://clojure.org/reference/metadata
- seanwilson 9y agoHmm, so I'm thinking about cases where you have 10K objects and you wouldn't want the metadata duplicated and attached to all of those. Would that happen in Clojure?
- snarfy 9y agoI think he wanted it to be something different than js, hence the focus on strictly data exchange. Why not use js for config instead of json? It's your app and your config so if you want it to look like json + comments + trailing comma you can. With so many options for config files like yaml, xml, heck even sqlite it does seem a bit silly how much json is used. Herd mentality.
- JaniceLeblanc 9y agoIt's an excelent reason in my opinion.
- guitarbill 9y agoComments also are a bit tricky to preserve when programatically modifying data structures, so a destructive minifier approach makes sense. Although it's very Javascript, "let's make another utility you now need". Crockford probably didn't think it would take off like it did, but with hindsight comments would have been the pragmatic choice IMO.