JSON is fine for inter-machine communication (like APIs). It's IMO terrible for human-to-machine communication (like configs), which is why there are so many alternatives trying to improve in this space (TOML, YAML, RON, etc.).
> Nothing will ever unseat JSON because whilst it's crap, it's good enough.
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.
That's why open source is not enough anymore, we need _lean_ open source, and that stable in time.
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 don't see this intended to unseat JSON. But it can be helpful for local testing and debugging of Rust projects. I wouldn't really expect this for general purpose serialization because JSON is more standard and for inner-app communication you can use something more compact.
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.
While I think (and lament) that you are almost right -- that is, that ridding the world of the foul pestilence that is JSON it will take insanely longer than it should -- I do think it will come a bit sooner than the heat death of the universe.
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
I think it will for config, simply because JSON doesn't support comments and that's really not an optional feature.
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).
I just wrote a little cli that takes JSON input, deserializes it into rust structs, serializes it into my custom binary protocol, sends it to my server I'm developing, and then does the reverse with the reply.
This looks like a nice replacement because it looks like the debug logs of my types. Plus it lets me specify numbers as hex.
We’re using something similar(ish) internally and it’s interesting how much more readable and expressive JSON can get by allowing Rust style constructors/tags for your data types.
Suddenly sum types become conveniently easy to express and understand, which is always incredibly awkward in JSON.
A big addition that json is missing a distinction for, which Ron has is the notion that hashmap and record/struct type are different. Hashmaps, you don't necessarily know what all the keys are. Structs, you know the keys and what type each key should be.
hashmap's a collection type, record/struct is a product type (tuple is another product type), many miss the sum type (incl JSON) sadly.
JS conflating the hashmap and record/struct is a big loss, probably fixed by TS. it does show JS's dedication to its radical dynamic typing discipline (or lack thereof).
Ron is quite practical if you are having a serializable interface, and you want to get debug like output from it for snapshotting purposes. I am using this with my insta snapshot testing library (https://insta.rs/) in some projects.
That's a big pet peeve for me as well! Only thing remaining now is those pesky colons (edit: was semi-colons) that everyone and their mother seems to place in their new formats. Just get rid of them already!
Who wants to type `{name: "pveierland"}` when you could just do `{name "pveierland"}`?!
Agreed. I don't know why "trailing commas allowed" is a plus -- it is not going to make things simpler or easy to maintain, and it is very questionable whether the added flexibility is worth it
As long as we are on topic of JSON alternatives suitable for configuration, I've been tinkering with various minimal syntaxes and formats for a long time, most notably Jevko[0].
One format based on that I've been conjuring up recently would represent the first example from the RON README like so:
GameConfig[ optional struct name
window size [[800] [600]]
window title [PAC-MAN]
fullscreen [false]
mouse sensitivity [1.4]
key bindings [
up [Up]
down [Down]
left [Left]
right [Right]
Uncomment to enable WASD controls
;[
W [Up]
A [Down]
S [Left]
D [Right]
]
]
difficulty options [
start difficulty [Easy]
adaptive [false]
]
]
I put a syntax-highlighted version and some more details in this gist[1].
I wonder what you guys think about such a minimal alternative.
The biggest advantage of json is its ease-of-use. It is super easy to get started, and once you are start using it to build a quick prototype, you are stuck with it.
And the customers of your api understand it as well, so you likely need to support json even if you may use something else internally.
It’s not intended to do that, and I don’t think that would be possible in general. Debug output can be arbitrary and ambiguous, while this is a well-defined serialization format that only happens to have a readable Rust-like syntax. Of course you’re always free to use RON in place of debug output for logging purposes.
What are the security implications? It sounds like they might be feeding the config text directly into Serde - which means allowing potentially untrusted user input to instantiate arbitrary structs. That's a big attack surface.
[+] [-] andrewstuart|2 years ago|reply
The toughest competition in the universe is a "good enough" competitor.
[+] [-] noctune|2 years ago|reply
[+] [-] the_mitsuhiko|2 years ago|reply
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.
[+] [-] sylware|2 years ago|reply
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...
[+] [-] kevincox|2 years ago|reply
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.
[+] [-] veidr|2 years ago|reply
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
[+] [-] maze-le|2 years ago|reply
[+] [-] hyperthesis|2 years ago|reply
[+] [-] IshKebab|2 years ago|reply
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).
[+] [-] iudqnolq|2 years ago|reply
This looks like a nice replacement because it looks like the debug logs of my types. Plus it lets me specify numbers as hex.
[+] [-] jasfi|2 years ago|reply
[+] [-] sfvisser|2 years ago|reply
Suddenly sum types become conveniently easy to express and understand, which is always incredibly awkward in JSON.
Besides that: tuples, tuple structs, comments, properly handling NaN, optional.
Really hope something like this takes over the role of JSON/yaml soon.
[+] [-] pdimitar|2 years ago|reply
[+] [-] maxloh|2 years ago|reply
[+] [-] habitue|2 years ago|reply
[+] [-] mjburgess|2 years ago|reply
[+] [-] cies|2 years ago|reply
JS conflating the hashmap and record/struct is a big loss, probably fixed by TS. it does show JS's dedication to its radical dynamic typing discipline (or lack thereof).
[+] [-] the_mitsuhiko|2 years ago|reply
[+] [-] pveierland|2 years ago|reply
[+] [-] codethief|2 years ago|reply
Personally, I really hope Human JSON, https://github.com/tailscale/hujson , will get more popular!
[+] [-] capableweb|2 years ago|reply
Who wants to type `{name: "pveierland"}` when you could just do `{name "pveierland"}`?!
[+] [-] hnarn|2 years ago|reply
> Note the following advantages of RON over JSON:
>trailing commas allowed
>single- and multi-line comments
>field names aren't quoted, so it's less verbose
>optional struct names improve readability
>enums are supported (and less verbose than their JSON representation)
I’m no fan of JSON but honestly, I think this is a very weak list of benefits if you’re trying to convince someone to switch.
[+] [-] rwalle|2 years ago|reply
[+] [-] Tuna-Fish|2 years ago|reply
> It's designed to support all of Serde's data model
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] djedr|2 years ago|reply
One format based on that I've been conjuring up recently would represent the first example from the RON README like so:
I put a syntax-highlighted version and some more details in this gist[1].I wonder what you guys think about such a minimal alternative.
[0] https://jevko.org
[1] https://gist.github.com/djedr/4eeac1de466512ec211ff17cfd1f5e...
[+] [-] orthoxerox|2 years ago|reply
[+] [-] fb03|2 years ago|reply
[+] [-] t43562|2 years ago|reply
e.g. Python Object Oriented Notation (POON) would have double quotes and True and False and "None" but otherwise be easily mistaken for JSON.
Scheme Object Notation Externtion (SCONE) would presumably just be a lot of brackets?
[+] [-] dmytrish|2 years ago|reply
I'd argue that toml can be called "a Python(ic) object notation" in some sense.
[+] [-] _vbnz|2 years ago|reply
Are there already parsers available for Scala, Python, Java, etc.?
[+] [-] vkakade|2 years ago|reply
And the customers of your api understand it as well, so you likely need to support json even if you may use something else internally.
[+] [-] ronyeh|2 years ago|reply
So all JSON is valid (modern) JavaScript. [1]
Is RON valid Rust?
[1] https://github.com/tc39/proposal-json-superset
[+] [-] hyperthesis|2 years ago|reply
[+] [-] krapp|2 years ago|reply
[+] [-] juliangmp|2 years ago|reply
[+] [-] pzmarzly|2 years ago|reply
[+] [-] codeflo|2 years ago|reply
[+] [-] the_mitsuhiko|2 years ago|reply
[+] [-] junon|2 years ago|reply
[+] [-] cies|2 years ago|reply
Also this is really cool when you want to upgrade your config file to a script!
It has comments! (looking at you JSON; pre-5 I know...)
[+] [-] ayhanfuat|2 years ago|reply
[+] [-] Findecanor|2 years ago|reply
Even though YAML was named "Yet Another Markup Language" in the beginning, it changed to "Yaml Aint a Markup Language" to emphasise that.
[+] [-] Ygg2|2 years ago|reply
[+] [-] tetromino_|2 years ago|reply
[+] [-] chrismorgan|2 years ago|reply
See, for example, https://github.com/ron-rs/ron/blob/484fcab0686dfd18c7e29b6c1..., where it (in a type-inferency way) says “parse as Config”.