Live data from Hacker News

TOML: Tom's Obvious Minimal Language

toml.io

11–20 of 229 posts

Re: TOML: Tom's Obvious Minimal Language

#11

The one thing I wish TOML had added was null. Today many TOML configs still have “nullable” keys which means you need to comment them out to unset them.

It's been discussed a few times over the years:

https://github.com/toml-lang/toml/issues/921

https://github.com/toml-lang/toml/issues/803

https://github.com/toml-lang/toml/issues/802

https://github.com/toml-lang/toml/issues/146

https://github.com/toml-lang/toml/issues/30

Obviously there is a bit of a demand, and it certainly has valid use cases, but also has downsides.

Re: TOML: Tom's Obvious Minimal Language

#12

The one thing I wish TOML had added was null. Today many TOML configs still have “nullable” keys which means you need to comment them out to unset them.

The Billion Dollar Mistake lives on. Personally I'm happy it doesn't have explicit null and somewhat surprised it supports NaN (which I thought it didn't) To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound.

CSS has two magic values that would be useful in many configuration scenarios:

- unset: ignore values of this property

- initial: use the default value

These would be useful e.g. with overrides.

I agree that nulls in a config files are often not a good idea because it is not clear how they are going to be interpreted.

PS: Css also has inherit that could mean "use the local default" while initial could mean use system default.

Re: TOML: Tom's Obvious Minimal Language

#13

Earlier quoted context omitted.

The Billion Dollar Mistake lives on. Personally I'm happy it doesn't have explicit null and somewhat surprised it supports NaN (which I thought it didn't) To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound.

> The Billion Dollar Mistake lives on. I disagree. There is a big difference between configuration language formats and programming languages. > To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound. I would agree, but in that case you now often need a secondary key to "turn something off" which is often not done.

> There is a big difference between configuration language formats and programming languages.

You're right! But in my opinion the difference is that a configuration file should have a default state that could be written to disk and loaded with no change in behaviour.

eg you can set `feature = "on"` or `feature = "off"` and if you don't set either it's the same as writing `feature = "off"`.

Having a secret third thing of `feature = null` should be outlawed and I'm glad TOML doesn't encourage it

Re: TOML: Tom's Obvious Minimal Language

#14

Earlier quoted context omitted.

The Billion Dollar Mistake lives on. Personally I'm happy it doesn't have explicit null and somewhat surprised it supports NaN (which I thought it didn't) To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound.

> The Billion Dollar Mistake lives on. I disagree. There is a big difference between configuration language formats and programming languages. > To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound. I would agree, but in that case you now often need a secondary key to "turn something off" which is often not done.

> There is a big difference between configuration language formats and programming languages.

In general: I agree. But configuration formats (including TOML) also need to map well to programming languages, so you can't seem them as entirely separate. One argument against Null is that it doesn't elegantly map to a data structure in all programming languages.

Re: TOML: Tom's Obvious Minimal Language

#15
post #12

Earlier quoted context omitted.

The Billion Dollar Mistake lives on. Personally I'm happy it doesn't have explicit null and somewhat surprised it supports NaN (which I thought it didn't) To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound.

CSS has two magic values that would be useful in many configuration scenarios: - unset: ignore values of this property - initial: use the default value These would be useful e.g. with overrides. I agree that nulls in a config files are often not a good idea because it is not clear how they are going to be interpreted. PS: Css also has inherit that could mean "use the local default" while initial could mean use system…

Unfortunately that's not what `unset` does and I feel like the confusion it causes and the complication it adds to any CSS parser suggests it's a bad idea!

Re: TOML: Tom's Obvious Minimal Language

#16
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

That's already fixed; in the upcoming TOML 1.1 you can write:

  tbl = {
     hello = "world",
  }
All the examples in the issue you linked should work.

https://github.com/toml-lang/toml/pull/904

Re: TOML: Tom's Obvious Minimal Language

#17

Earlier quoted context omitted.

> The Billion Dollar Mistake lives on. I disagree. There is a big difference between configuration language formats and programming languages. > To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound. I would agree, but in that case you now often need a secondary key to "turn something off" which is often not done.

> There is a big difference between configuration language formats and programming languages. You're right! But in my opinion the difference is that a configuration file should have a default state that could be written to disk and loaded with no change in behaviour. eg you can set `feature = "on"` or `feature = "off"` and if you don't set either it's the same as writing `feature = "off"`. Having a secret third thing…

There is a secret third thing called "feature not in file" and most TOML implementation encourage it as "key not in file" is typically returned as `null` or `None`. That's how so many TOML files in practice end up with all these secret values.

It's also particularly odd in lists where I have seen `["foo", "bar", {}]` show up in the real world with `{}` being used as a replacement value for null.

Re: TOML: Tom's Obvious Minimal Language

#18
post #14

Earlier quoted context omitted.

> The Billion Dollar Mistake lives on. I disagree. There is a big difference between configuration language formats and programming languages. > To my mind, a configuration file using "this key doesn't exist" as one of several valid options seems deeply unsound. I would agree, but in that case you now often need a secondary key to "turn something off" which is often not done.

> There is a big difference between configuration language formats and programming languages. In general: I agree. But configuration formats (including TOML) also need to map well to programming languages, so you can't seem them as entirely separate. One argument against Null is that it doesn't elegantly map to a data structure in all programming languages.

> One argument against Null is that it doesn't elegantly map to a data structure in all programming languages.

TOML has plenty of constructs that don't map well to many languages. Plenty of language implementations do not know how to work with the datetime type, some TOML implementations barf on objects in lists. In some TOML implementations you also end up with nulls showing up when certain empty table constructs are used.

Re: TOML: Tom's Obvious Minimal Language

#19
post #4

The one thing I wish TOML had added was null. Today many TOML configs still have “nullable” keys which means you need to comment them out to unset them.

Well that would be null right? an absence of the thing.

Null is one way to represent such a value, but it’s hardly the only.

Option-style algebraic types are another, and more or less strictly superior if working in a language with first class support for such, because they force you to explicitly handle the null/None/Empty/whatever case if you’re doing something with it that could fail (basically anything besides assignment or passing it along).

Re: TOML: Tom's Obvious Minimal Language

#20

Earlier quoted context omitted.

> There is a big difference between configuration language formats and programming languages. You're right! But in my opinion the difference is that a configuration file should have a default state that could be written to disk and loaded with no change in behaviour. eg you can set `feature = "on"` or `feature = "off"` and if you don't set either it's the same as writing `feature = "off"`. Having a secret third thing…

There is a secret third thing called "feature not in file" and most TOML implementation encourage it as "key not in file" is typically returned as `null` or `None`. That's how so many TOML files in practice end up with all these secret values. It's also particularly odd in lists where I have seen `["foo", "bar", {}]` show up in the real world with `{}` being used as a replacement value for null.

In my experience (Python and Rust) missing keys are errors, not silently converted to None:

    In [1]: example = {"foo": None}

    In [2]: print(example["foo"])
    None

    In [3]: print(example["bar"])
    ---------------------------------------------------------------------------
    KeyError                                  Traceback (most recent call last)
    Cell In[3], line 1
    ----> 1 print(example["bar"])

    KeyError: 'bar'

    In [4]: print(example.get("bar", "sensible default"))
    sensible default
If configuration values were arbitrarily nullable I would either need to deal with the possibility of nulls ending up anywhere in my program (back to The Billion Dollar Mistake) or have to have checks on parsing to say which fields are nullable or not.

I acknowledge people have done silly things regarding missing keys already - but I think they should be discouraged from continuing to do so, not enabled.

Post reply on HN