Follow

JSON is a bad config file format

For the record, INI files or TOML is better

@sir Depends. Human-written configuration: Definitely. But machine-generated configs? It's not worse than the other formats.

@bfiedler @sir

>> JSON is a bad config file format

> Depends. Human-written configuration: Definitely. But machine-generated configs? It's not worse than the other formats.

Well, I'd argue that a file is intended to be read/written *only* by a computer isn't really a config file – it's a bit of serialized data (which is only incidentally config data). And storing serialized data *is* one of the few good use-cases for JSON.

But I acknowledge that might be splinting semantic hairs

@tuxcrafting @xerz yes, but I would sooner use it than JSON in some use-cases.

@tuxcrafting @xerz just because cars are bad doesn't mean I'd make a cross-country trip on a boat

@xerz
Yaml is fucking garbage, I'd rather write json by hand
@sir

@sir Yes, but I don't know that YAML is much better.

I've met a few too many people who seemingly cannot tell 3 spaces apart from 4 spaces.

There's always a tough choice between super simple config style and support for lists and dicts.

The latter isn't always required, but it's always annoying when you suddenly do need it.

@sir thoughts on toml as a configuration file format? Seems like one of the better ones out there atm.

@net it's fine but if you can get away with INI you should use that instead

@sir @net What's the advantage of INI over toml? It isn't really specified, while toml is, is it?

@xsteadfastx it's alright for a few specific use-cases, but it's also a footgun so it should be used with care. It's also way too complicated and I would never want to write an implementation

@sir just offtopic but its like my personal hero just answered me ;-)

@sir TOML might be the best thing to happen to config files since sliced bread.

JSON is fine as a human-readable interchange format, but really annoying to write by hand.

@mort @sir Wait.. you used to write your config on sliced bread??

@rune @mort @sir
yeah, that was popular before punchcards became a thing.

But even earlier than sliced bread, we used to write configs on clay tablets.
Now some people write configs on glass tables, so you could say we've come a full circle.

@wolf480pl @rune @mort @sir

> But even earlier…, we used to write config [files] on clay tablets.
Now some people write config [files] on glass tables, so you could say we've come a full circle.

This is exactly the sort of content I come to Mastodon for, nicely done. :D

@sir Didn't you some time ago say something against programming languages without a specification? I mean clearly it's not exactly the same, but INI files are parsed differently between parsers while TOML files aren't. I wouldn't use INI for new projects anymore.

@geosum there's very little need for the format of your config file to be portable between applications. What are you going to do, hand your .vimrc to Firefox?

@sir @geosum you could be interested in scripting some config changes of Firefox config or another app from a Python script for example.

@sir What I actually meant was that you can get familiar with toml once for all applications that use it. For INI, you could configure two applications where one of them supports something the other doesnt for the configs syntax-wise which would be confusing.

@sir when wrestling with a TOML config that gets into the deeply-nested dicts, I wish they'd just use json or yaml instead.

@sir I ended up doing a config file format based on Python's indentation philosophy. It doesn't take much to parse:
sources.vsta.org:7100/chore/ar
and config files can be moderately complex/nested while staying human editable, for instance:
sources.vsta.org:7100/tis/arti

@vandys this seems pretty decent but you should put it on 443 and add https

@sir In general, there's support in that middleware for SSL:
sources.vsta.org:7100/tis/arti
TIS doesn't use it because we can't afford to have certs expire during a disaster (or assume that we can reach a CA if they do)

@vandys you can make certs update themselves, this is no excuse

@sir If you have Internet. That thing is for DISASTER operations. You don't know when it'll happen, or how long it'll last. Totally different design space from securing the net for commerce.

@vandys you can do weekly renewals to get 80-90 days of working cert, or you can still buy certs for terms like 1 year+, or you can offer both with and without https. And if you don't have internet you're not going to reach this web host anyway. Give me a break

@sir You don't appear to know much about deploying disaster networks. Let's leave it at that.

@vandys I know plenty, but you seem to prefer thinking of me as having the average intelligence of /dev/null rather than step one toe outside of your ivory tower of ignorance. I hope you get MitM'd, twit

@sir hard agree on TOML being better, in almost (read: every) situation it's more clear and understandable to people and easier to parse.

@sir I just know I don't like complex formats or difficult parsing. Also, a config file format really needs comments, which JSON technically doesn't support AFAIK.

So yes, JSON is bad, but TOML is also already a little too much for me...

If you ask me, INI is great for that job. Sometimes I think that Lua is great, too. But then: loops in config are kinda overkill and can result in denial of service.

@prashere it's easier for machines to write than humans. Too many rules for humans to be aware of and deal with, like trailing commas, quoting everything, escaping stuff, no support for multi-line strings...

@sir have you heard of XML? It's the perfect format for any serial data! :^)

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!