Live data from Hacker News

TOML: Tom's Obvious Minimal Language

toml.io

81–90 of 229 posts

Re: TOML: Tom's Obvious Minimal Language

#81
post #10

JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (being both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1]. [1] https://github.com/toml-lang/toml/issues/516

Maybe you could even skip the commas entirely (or threat newlines as commas if possible?) That, along with unquoted keys, would make JSON perfect for me.

In such a hypothetical format, eliminating nulls entirely should Also be considered, the difference between a missing key (undefined) and a null value is significant in JS, but other (particularly statically-typed) languages struggle with differentiating those two cases, and this leads to `serialize(deserialize(a))` representing a different document than `a`.

Re: TOML: Tom's Obvious Minimal Language

#82
post #10

JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (being both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1]. [1] https://github.com/toml-lang/toml/issues/516

Everything is perfect except for the reasons it isn't.

Re: TOML: Tom's Obvious Minimal Language

#83
post #10

JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (being both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1]. [1] https://github.com/toml-lang/toml/issues/516

> JSON is basically perfect if it allowed trailing commas and comments. I agree, especially in regards to the comments, because sometimes the data itself isn't enough and additional human-readable context can be really useful! In that regard, JSON5 is a wonderful idea, even if sadly it isn't widespread: https://json5.org/ It also supports the trailing commas and overall just feels like what JSON should be, to make it…

I like the idea of JSON5, but it allows a bit too much in my opinion. For example, why add the single quote? Why hexadecimal identifiers?

Re: TOML: Tom's Obvious Minimal Language

#84
post #43
post #10

JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (being both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1]. [1] https://github.com/toml-lang/toml/issues/516

The problem with comments in configuration files is that they don't survive a `load -> native object -> save` round-trip.

They could if you parsed it into syntax tree wit some methods to access keys instead of parsing into native struct. I think I saw YAML parser doing it...

Re: TOML: Tom's Obvious Minimal Language

#85

I pretty like the idea of a superset of JSON that supports (1) comments, (2) trailing commas, (3) unquoted properties, (4) optional {} for the root object, (5) multi-line strings, (6) number separator. JSON6 proposal [1] supports all of this, except (4). Unfortunately it also supports more and make the spec a bit too complex for my taste (JSON has a compact spec; any extension should honor this). Same issue with JSON…

>I pretty like the idea of a superset of JSON that supports (1) comments, (2) trailing commas, (3) unquoted properties, (4) optional {} for the root object, (5) multi-line strings, (6) number separator.

You're 90% way there to YAML.

And YAML 1.2 cleaned up most of the annoying YAML edgecases too

Re: TOML: Tom's Obvious Minimal Language

#86
post #83

Earlier quoted context omitted.

> JSON is basically perfect if it allowed trailing commas and comments. I agree, especially in regards to the comments, because sometimes the data itself isn't enough and additional human-readable context can be really useful! In that regard, JSON5 is a wonderful idea, even if sadly it isn't widespread: https://json5.org/ It also supports the trailing commas and overall just feels like what JSON should be, to make it…

I like the idea of JSON5, but it allows a bit too much in my opinion. For example, why add the single quote? Why hexadecimal identifiers?

JSON is trash and should never be used in any human-interfacing context, so I'm super skeptical that there's any utility in trying to fix it; that would just delay its demise, to the detriment of humankind.

But if you did want to fix JSON, the yes, trailing commas and comments are the absolute minimum bar, but single quote is actually probably the the third absolute must-fix.

The reason is just that so much JavaScript tooling is now configured to autoformat code (including the JSON bits) to swap " to ', thanks in large part to Prettier (which also should almost never be used, sigh, but that's a topic for another HN bikeshed...)

hexadecimal identifiers, yeah, nah

Re: TOML: Tom's Obvious Minimal Language

#88
post #75

Earlier quoted context omitted.

JSON allows you to store arbitrarily large integers/floats. It's only in JS this is a problem, not if you use JSON in languages that support larger (than 54-bit) integers.

That's the freedom of unspecified behavior.

As long as the same person is on both sides of a communication channel, he has total freedom on what to say and will understand it flawlessly!

That's what standards are for, isn't it?

Re: TOML: Tom's Obvious Minimal Language

#89
post #66
post #10

JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (being both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1]. [1] https://github.com/toml-lang/toml/issues/516

I kinda agree, but I also think then you want unquoted keys {name: "value"} And then maybe 123_456 syntax It's a slippery slope ... pretty soon it's hard to write a JSON parser, and there are more bugs The trailing comma one is trivial, I'll grant that

Trailing commas a very highly impactful to the users, and trivial to the language writers.

The 123_456 syntax comes close to that, but is much less impactful.

None of those will make the language hard to parse.

Re: TOML: Tom's Obvious Minimal Language

#90
post #37

My main issue with TOML is precisely described in the homepage example: [servers] [servers.alpha] is error prone. An sub heading shouldn't need to know about its parent, much less to have to copy it entirely.

But then you need new syntax to indicate subheadings, which is also (probably less) error prone because you might omit it.
Post reply on HN