The toughest competition in the universe is a "good enough" competitor.
The toughest competition in the universe is a "good enough" competitor.
Cool indeed. I wonder how you can supply it with types from the program that consumes the config.
My Gradle config is in Kotlin these days. Kotlin, besides being a full blown prog lang, has nice features for config specs (map/list literals, typed, eDSL syntax). Though it is an enormous dependency (way to big for a project that just needs a config file format).
If your language has an OpenAPI library, you can create a hello-world web app that exposes your configuration object as an HTTP endpoint, and generate Dhall types from that.
But this turns out to support OP's point. JSON is good enough, and there are many alternatives that we are debating and don't agree on.
So if you have to pick something, and I have to pick something, since we don't agree, we will fallback on JSON.
Where JSON mainly fails as config format is lack of comments. Comment provide help and structure when editing. While allowing to toggle functionality. Which is where trailing commas help.
Use a prettifier plugin in your editor or squint, silly human. Trailing-comma-on-write-annoyance-adjuster, bada-bing, bada-boom. Most of the peeves can be hidden with good tooling. This Ron thing makes sense because of Serde not because it is prettier.
Here's a rundown of HOCON's main features: https://github.com/lightbend/config#features-of-hocon
JSON is "secretly" being replaced by JSON5 in quite a lot of contexts. So I'm not sure that this is entirely accurate. The same was said about XML a long time ago and people claimed that XML will never be replaced. Yet today XML is barely used any more. Likewise TOML is showing up in more and more places were previously INI or YAML was the standard.
TOML for example is extensively used in the Rust world, but if you're doing PHP, you're much more likely to deal with XML or JSON than TOML on a daily basis.
Formats come and go over time, surely JSON will as well.
JSON5 parsing is unfortunately slower than JSON. Not intrinsically, but JSON.parse/stringify are both natively implemented and highly optimized. If browsers started supporting it, it would take off overnight. I can't tell you how often I've wanted to put comments or not worry about removing the last trailing comma from a list.
It would win for some of the same reasons HTML5 beat XHTML. Ease of use and implicit rules beat pedantic strictness any day of the week. "Programmers are lazy."
Kudos to Asheem and all JSON5 team for building a great product while ignoring the haters [1]
[1] https://aseemk.substack.com/p/ignore-the-f-ing-haters-json5
Big Tech is based mostly on 2 related scams: planned obsolescence and grotesquely and absurdely massive and complex open source software/standards/protocols.
To protect us against them, is to go to simple but able to do a good enough job and stable in time protocol/standard/open source software/etc. You will need lawyers.
This is common sense, but many seem to lose it... more or less sincerely...
I did actually use this in a project because it differentiates between nesting of Option. Particularly we were having some confusion of Some(None) and None and this helped our tests catch more issues. In production we used JSON. Serde makes it trivial for the same code to switch between formats.
The reason I think so is that so many JSON users are no longer actually using JSON. Although there are apparently several competing implementations still vying for the name "JSONC", one of those is the non-JSON format that allows comments used by VS Code (among many others), and it is spreading (often inadvertently).
This weakens JSON by diluting the meaning of the term (many users of this "JSON plus comments" think they are using JSON). The end result might be that we standardize on some "JSON+" type name, or that the meaning of "JSON" itself is diluted to include such superior mutations.
Either way is pain in the ass, though, because JSON is a human-readable format (I mean, not really, but in practice), but it is also a machine-to-machine format, so deviation from the spec is certainly unhelpful there.
But we got rid of Latin-1 and SJIS (for the most part), and I have hope that in the fullness of time, we'll get rid of JSON, too. (Probably not with RON, though.)
P.S. Nrwl guys, JSON config files are literally the most painful part of using Nx, and you should consider just using TypeScript, but if not, "VS Code style comments-enhanced JSON" would still be a massive improvement. :-D
But I have tried lots of alternatives and none have as good tooling except maybe XML. Especially for schemas, which I think is really important.
I want JSON5 to succeed but there's no good IDE support really.
I also tried Dhall, which looks promising except they've imported all the super weird stuff from functional languages that are just going to put people off (e.g. the weird leading commas, and very odd way of declaring functions).
This looks like a nice replacement because it looks like the debug logs of my types. Plus it lets me specify numbers as hex.