Live data from Hacker News

Toml: Tom's Obvious, Minimal Language

github.com

131–140 of 204 posts

Re: Toml: Tom's Obvious, Minimal Language

#131

Earlier quoted context omitted.

This JSON is vastly more readable, frankly. It’s so clear what container type “designers” refers to, and I can read directly what data structures the elements are. I can’t do that in Toml. Unless I just happen to remember some rote memorized convention for what the syntax unpacks into, there’s no way to tell by looking at Toml code. IMO this ought to be priority number one for any utility language like this. No matte…

I think you're focusing on TOML's weakest case here. I think for a lot of configuration files, TOML is going to be easier to read and write. Personally, I'd rather have a configuration file that looks like this: [site] name = "My Great Website" url = "https://example.com" author = "Watts Martin" email = "foo@bar.com" links = [ { name = "tom", url = "http://tom.example.com" }, { name = "bob", url = "http://bob.example…

Actually, even here in your extended example, the JSON is the easiest to read. For durable files that will be read much more than written, saving a few newlines or keystrokes is super irrelevant, but JSON gives such explicit understanding of the data structures and nesting, which IMO is really confusing and hard to understand in Toml.

I can agree Toml is sometimes better than YAML, but I cannot agree it is better than JSON. For me JSON is so simple, so easy to read, it has the nice feature of preventing comments and multi-line strings to keep things extremely simple and to enforce that documentation about the values in the file has to be located outside the file, as it absolutely should (documentation should be at the site that uses the config/param file, not inside it).

Plus, I find JSON indentation to be a real joy to assist with reading and seeing the nested structure. That indentation is optional in Toml, but I think pretty much always the use of that indentation ought to be enforced as a convention for people using Toml. Lacking the indentation is really not good for config / parameter files.

Re: Toml: Tom's Obvious, Minimal Language

#132
post #124

Earlier quoted context omitted.

It's kind of similar to the syntax of uri query strings and the php syntax for appending to arrays, in that an extra pair of square brackets indicates appending: In php: $a[] = 1; $a[] = 2; # $a == array(1, 2) In URIs: http://example.org/?a[]=1&b[]=2 Compare to TOML [[a]] item = 1 [[a]] item = 2

That URI syntax is just a convention used by some web frameworks. You can just as well write https://example.org?foo=bar&foo=baz

Not for PHP at least, maybe others, the last query arg will win.

Re: Toml: Tom's Obvious, Minimal Language

#133
post #128

Earlier quoted context omitted.

I used to feel this way, and also used to be frustrated about multi-line strings in JSON. With years of experience now, though, I actually appreciate JSON omitting these features. Config files should absolutely not have or need comments. If you need them directly in the config file, something is wrong. Applications should document their default settings in a different way, preferably in a README or generated document…

> I actually appreciate JSON omitting these features. I guess this is right if config files are only machine read and written. When I am prototyping, config auto-gen tends to come pretty late in the project (for me), and I like being able to comment things. I also like types and time-date parameters (which JSON doesn't provide unambiguously), so by the time I've done, I've reinvented YAML+, and that's a mess, so I ac…

> "I guess this is right if config files are only machine read and written."

No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters.

A config file is just some file. Its contents have no conventional meaning. It only takes on a meaning in the context of the specific system that uses it.

Re: Toml: Tom's Obvious, Minimal Language

#134
post #89
post #71

Earlier quoted context omitted.

Backslashes are valid characters in a POSIX filesystem, but they don't indicate a directory.

Yeah...rather than validating paths, the better use case is probably normalizing them so that you don't need platform-specific configuration files. Being able to write: static-files = path/to/static/files And have it work on all platforms gives a distinct advantage over specifying paths as strings.

That was my first thought, but imo such a functionality belongs in the language's file access library.

Re: Toml: Tom's Obvious, Minimal Language

#135
post #85

Earlier quoted context omitted.

Yeah, most of TOML looks good, but the .INI style [table] and even wierder the [[table-array]] thing seems like they were trying to hammer a square peg into a round hole for the sake of having config files that look like INIs.

Backwards-compatibility with ini is in my opinion one of the more powerful aspects of TOML which help adoption. Kinda like how UTF8 is ASCII-backcompatible.

[deleted]

Re: Toml: Tom's Obvious, Minimal Language

#136
post #128

Earlier quoted context omitted.

> I actually appreciate JSON omitting these features. I guess this is right if config files are only machine read and written. When I am prototyping, config auto-gen tends to come pretty late in the project (for me), and I like being able to comment things. I also like types and time-date parameters (which JSON doesn't provide unambiguously), so by the time I've done, I've reinvented YAML+, and that's a mess, so I ac…

> "I guess this is right if config files are only machine read and written." No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. A config file is just some file. Its contents have no conventional meaning.…

Hugely disagree. Config files will modified by non-experts of the application 1000x as often as the actual developer of the application. Those people won't and often can't go look at the code.

Also, it can be really hard to find where exactly a configuration value is used. You may have to trace through a ton of code to find the place, and then you can't be sure that's the only place it's used.

Configuration comments are crucial, both for onboarding new users (explaining what the default is if you don't set a value, explaining what the configuration value actually controls, etc) and for experienced users to tell others why this esoteric configuration is set the way it is.

A configuration file is literally just a stack of magic numbers and strings. Why are we setting threadpool to 10 and not 1000? Why are we disabling X feature? What the heck does TPS_Report=true do?

You need comments.

Re: Toml: Tom's Obvious, Minimal Language

#137
post #128

Earlier quoted context omitted.

> I actually appreciate JSON omitting these features. I guess this is right if config files are only machine read and written. When I am prototyping, config auto-gen tends to come pretty late in the project (for me), and I like being able to comment things. I also like types and time-date parameters (which JSON doesn't provide unambiguously), so by the time I've done, I've reinvented YAML+, and that's a mess, so I ac…

> "I guess this is right if config files are only machine read and written." No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. A config file is just some file. Its contents have no conventional meaning.…

That might be correct. I tend to want to localize explanation at the edge. I've got to think about this. Thank you.

Re: Toml: Tom's Obvious, Minimal Language

#138

Earlier quoted context omitted.

> "I guess this is right if config files are only machine read and written." No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. A config file is just some file. Its contents have no conventional meaning.…

Hugely disagree. Config files will modified by non-experts of the application 1000x as often as the actual developer of the application. Those people won't and often can't go look at the code. Also, it can be really hard to find where exactly a configuration value is used. You may have to trace through a ton of code to find the place, and then you can't be sure that's the only place it's used. Configuration comments…

I disagree strongly. Config files being modified by anyone should be going through code review. The risk of not understanding while at the same time modifying things is extremely low.

Plus, the documentation in the application code that loads the config and manipulates would function as the exact same reference documentation for any developer trying to understand how the config is used or why a choice is made.

This prevents the documentation about what the config is supposed to be used for from being coupled with the implementation detail of what particular config file looks like, what language it’s written in, etc.

Just as you say, a config file is a stack of magic constants. They have no meaning at all sitting in that file. The place to look for their meaning is the documentation of the code that loads the file, which should tell the user everything they need to know about modifying or providing their own file.

Re: Toml: Tom's Obvious, Minimal Language

#139
post #128

Earlier quoted context omitted.

> I actually appreciate JSON omitting these features. I guess this is right if config files are only machine read and written. When I am prototyping, config auto-gen tends to come pretty late in the project (for me), and I like being able to comment things. I also like types and time-date parameters (which JSON doesn't provide unambiguously), so by the time I've done, I've reinvented YAML+, and that's a mess, so I ac…

> "I guess this is right if config files are only machine read and written." No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. A config file is just some file. Its contents have no conventional meaning.…

>They belong in the sections of code that load specific config files and convert their contents into defaults or parameters.

And what are users who don't have access to the source, or who aren't programmers, supposed to do?

Re: Toml: Tom's Obvious, Minimal Language

#140

Earlier quoted context omitted.

> "I guess this is right if config files are only machine read and written." No, I meant omitting these features is very useful for humans reading and writing config files. Comments utterly don't belong in config files. They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. A config file is just some file. Its contents have no conventional meaning.…

>They belong in the sections of code that load specific config files and convert their contents into defaults or parameters. And what are users who don't have access to the source, or who aren't programmers, supposed to do?

Somehow these people are reading Toml files of config? That’s silly.
Post reply on HN