Live data from Hacker News

TOML – Tom's Obvious, Minimal Language

toml.io

81–90 of 163 posts

Re: TOML – Tom's Obvious, Minimal Language

#81
post #2

I've always had a soft spot for the classic .INI style configuration. Modding command and conquer through "rules.ini" was always an adventure.

I also like how it just does one thing: key/values. It doesn’t try to be a complex serialization format or its own full language - it’s just keys and their values. Granted, sometimes data needs to have more structure, but for settings/flags INI is very good.

Re: TOML – Tom's Obvious, Minimal Language

#82
post #30
post #13

Earlier quoted context omitted.

I recently wrote a TOML parser in Idris2. It's a cool language, but has some quirks. For me, it's that it's just a simple KV store with some sugar (that's nice!) but it also means that a lot of information is lost forever in parsing. For example, these two documents are strictly identical: [info] name = { first="bob", last="jones" } and info.name.first="bob" info.name.first="jones" This can be seen as a positive (it'…

Can you expand on the negatives? I don't think I understand what you mean.

I believe the main negative he is referring to is that there is no canonical representation for a given document. The input file can be structured to share common keys (in the example above it's `info`) or not. Since both inputs are parsed into the same value it means that writing a printer is harder: you now have the choice between different output representations.

As a comparison, there's not much choice when serializing to JSON - the only variation is around whitespace. When serializing TOML you need more insight to decide what's the best representation for a human. A contributing factor to this issue is that TOML is mostly used for configuration files, so it often matters that the output is readable.

Re: TOML – Tom's Obvious, Minimal Language

#83
I had tons of headaches trying to get toml to do what's trivial in Json (nested arrays of objects of arrays of ... etc). 1/10 would not try again. For very simple, hear "flat" config it checks out. But then, so does yaml or even ini files. Anything requiring composite types was just a nightmare. I'd even prefer xlm before using toml again.

Re: TOML – Tom's Obvious, Minimal Language

#84
post #78
post #65

Earlier quoted context omitted.

> the standard library is where packages go to die I totally understand that sentiment. But that does seem to contradict the "batteries included" philosophy. Then again pip itself seems like one of the batteries you would expect to be included, so maybe that philosophy is just no longer as relevant to python.

Python now includes pip itself in the standard library (which is a spectacularly poor decision IMO).

Nit: the standard library includes a module to fetch and install pip. It doesn't include pip itself.

Re: TOML – Tom's Obvious, Minimal Language

#85

Of configuration file formats, TOML is my favorite. It hits the right balance of power and simplicity, it's been able to handle my needs with minimal effort and fuss. I tried Python's INI for configuration, but it was both too simple and too complex at the same time, very frustrating. YAML is a nightmare, the formatting is way too easy to get wrong and accidentally break your configuration. JSON is too strict/simple.…

JSON is too strict/simple This is why I like JSON! I have seen the horrors of XSLT and I’m never going back.

IMO it kind of sucks that you're not able to add comments to JSON easily.

In TOML (or YAML) it's just as easy as prepending it with # at the beginning of the line.

Re: TOML – Tom's Obvious, Minimal Language

#86

YAML and TOML wouldn't have been necessary if JSON had been slightly more expressive. If JSON had * comments * bareword (not double quoted) object key names it'd be a much more suitable configuration file format for everything, and I don't think we'd see the motivation to make things like TOML and YAML.

YAML and JSON are about the same age: YAML dates from 2001 and JSON 2001/2.

Re: TOML – Tom's Obvious, Minimal Language

#87
post #9

I was constantly reading/writing config files and the structure and comments were what convinced me TOML was worth to try. I did end up going back to JSON for the schema validator bit, but I just found out that TOML is still working on it: https://github.com/toml-lang/toml/pull/116

IF you need schema validation, you should probably be using XML

Re: TOML – Tom's Obvious, Minimal Language

#88
post #31

TOML sucks in so many ways. It is about 8x better than YAML, INI, or JSON though. It is good enough that I can ignore its flaws.

JSON should be banned for configuration, if only for the fact it doesn’t support comments.

Yes. It's crazy that people somehow decided that XML is evil for configuration and JSON is good. YML is barely OK.

JSON is good for data exchange. Configs? That's crazy talk.

Re: TOML – Tom's Obvious, Minimal Language

#89
post #43

Earlier quoted context omitted.

It's about strong typing. I detest stringly-typed programming. If the format specifies some stronger types, the decoders can "bubble that up" to the programming language that decode the file. E.g.: a guid turns up as a "System.Guid" type in C# instead of "System.String". This matters, because all of these are the "same" GUID, but not all GUID parsers can handle all of these formats: {123e4567-e89b-12d3-a456-426652340…

Surely you shouldn’t be limited to types as interpreted and represented in the low-level config parser library but should have a strongly typed representation i of the config structure that you implement in whatever language you’re using. C# is a good example. JSON doesn’t have any of these types. It doesn’t even make a distinction between integers and other numbers. Yet it’s common practice to marshal these into the…

> At the end of the day, if you type it with your keyboard, it’s essentially a string.

I mean .. yes, but that's the exact chaos we're trying to mitigate? The different types may all get serialised as strings, but their semantics are different. And the purpose of strong typing is to make it harder for people to put semantically wrong things in the wrong place.

(This is semantic markup vs all over again, isn't it)

Re: TOML – Tom's Obvious, Minimal Language

#90
post #21

TOML superficially looks clean, but it has many of the same problems other similar languages have. Such file formats are typically used for configuration files. Yet, a substantial amount of effort was expended on data types not commonly seen in configuration files, such as a date-time-offset. Meanwhile, much more common data types typically used in configuration files is missing, such as GUIDs, IP Addresses, and byte…

This is a table. Let's see it do a tree. (And not an adjacency matrix. That's cheating.)

A tree is a graph without cycles. A graph is a relational structure E(a,b) which can easily be stored in tables. This is why relational databases like SQL store tables. So there's nothing exceptional about storing graphs, and adjacency lists or matrices are all fine.

To connect with the other threads, SQLite would be probably the best candidate proposed here to store a tree.

Post reply on HN