Re:I accidentally used YAML.parse instead of JSON.parse and ...
by zarzavat on Sunday January 23, 2022 @09:18PM
(#30052911)
We do, it’s called TOML. The future is here it’s just not equally distributed.
[ Parent
| on HN ]
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by SPBS on Sunday January 23, 2022 @10:14PM
(#30053312)
TOML sucks for list of tables simply because they intentionally crippled inline tables to only be able to occupy one line. For ideology reasons ("we don't need to add a pseudo-JSON"). Unless your table is small, it's going to look absolutely terrible being all crammed into one line.
https://github.com/toml-lang/toml/issues/516
The official way to do list of tables is (look at how much duplication there is)
[[main_app.general_settings.logging.handlers]]
name = "default"
output = "stdout"
level = "info"
[[main_app.general_settings.logging.handlers]]
name = "stderr"
output = "stderr"
level = "error"
[[main_app.general_settings.logging.handlers]]
name = "access"
output = "/var/log/access.log"
level = "info"
vs handlers = [
{
name = "default",
output = "stdout",
level = "info",
}, {
name = "stderr",
output = "stderr",
level = "error",
}, {
name = "access",
output = "/var/log/access.log",
level = "info",
},
]
I would still reach for TOML first if I only needed simple key-value configuration (never YAML), but for anything requiring list-of-tables I would seriously consider JSON with trailing commas instead.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by zarzavat on Monday January 24, 2022 @12:17AM
(#30053976)
I see the point and this is certainly a drawback of TOML but for me this is something of a boundary case between configuration and data.
When configuration gets so complicated that the configuration starts to resemble structured data I tend to prefer to switch to a real scripting language and generate JSON instead.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by CameronNemo on Monday January 24, 2022 @12:37AM
(#30054068)
Expression languages like Nix, Jsonnet, Dhall, and Cue are really nice in these situations.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by bin_bash on Sunday January 23, 2022 @10:39PM
(#30053456)
for this reason I couldn't see a CI platform ever seriously consider TOML
(someone may point out to me a CI platform that relies on TOML—which I welcome)
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by colejohnson66 on Sunday January 23, 2022 @11:28PM
(#30053750)
Rust is built on TOML. For better or worse.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by notriddle on Monday January 24, 2022 @12:19AM
(#30053980)
Do you mean Cargo? Because Cargo is not a CI system. You never embed shell commands in a Cargo.toml.
If you need to program complex logic to build a crate, you don’t write TOML. You write a build.rs file in actual Rust.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by Too on Monday January 24, 2022 @12:49AM
(#30054120)
If embedding shell commands in a configuration language is considered a CI system I think we are doomed.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by Dylan16807 on Monday January 24, 2022 @12:51AM
(#30054131)
> JSON with trailing commas
JSON5?
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by Tesl on Sunday January 23, 2022 @09:27PM
(#30052987)
It's perfect until you do a lot of nesting..
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by donio on Sunday January 23, 2022 @11:18PM
(#30053691)
...or any nesting. TOML sucks for anything non-trivial.
Re:I accidentally used YAML.parse instead of JSON.parse and ...
by 41b696ef1113 on Sunday January 23, 2022 @09:40PM
(#30053085)
It makes me sad every time I see a newly announced tool that went for YAML instead of TOML.