Live data from Hacker News

Why do so many tools have JSON config files?

textlog.cc

51–60 of 78 posts

Re: Why do so many tools have JSON config files?

#51
post #29

Earlier quoted context omitted.

Can you show an example of how you use SQLite for _config_ files?

SQLite is a tiny relational db that essentially runs right in the same folder as your application. No connection other than connecting from the app itself to the SQLite.db sitting next to it.

You're missing the point: Why are your config files so complicated that you need SQLite?

I've shipped a product that used SQLite, and we actively removed configuration from SQLite. It was a lot easier to diagnose issues when configuration was in text files, because non-programmers could kinda-sorta understand them without needing to learn how to use SQL.

Re: Why do so many tools have JSON config files?

#52
post #26
post #10

Earlier quoted context omitted.

> The LLM output could then be any format that's easy and unambiguous to parse. Thats the problem isnt it? LLMs arent deterministic. Terrible for prod

Llms are absolutely deterministic if you want them to be. Still a terrible idea for config

Don't you need the same model, on the same hardware, with the same prompt, and temperature set to 0 to make it deterministic?

Re: Why do so many tools have JSON config files?

#53
post #16
post #15

because JSON is in the following sense "universal": every format/structure that has numbers, strings, booleans, null/none, finite lists of items, and string-indexed records of items already contains JSON and that's pretty much the barebones you need for a configuration language (of course you can argue about the syntax)

Lack of comments is pretty big though for a human editable config .

I just put them in as values. In a GUI I sometimes render them as a editable textarea.

Re: Why do so many tools have JSON config files?

#54
post #39

For Caddy we chose JSON because it's fairly universal, maps nearly 1:1 with Go structs (useful for initializing an extensible server), and nearly everything else compiles to JSON one way or another, so you can choose your own config format, really: https://caddyserver.com/docs/config-adapters

Hey, thanks for Caddy! It's awesome :).

Re: Why do so many tools have JSON config files?

#55
post #23

> A lot of tech folks resist documentation because they think it provides them with job security. No, we're just lazy.

Which is better than the all too common middle ground: writing something once and then not maintaining it. I've been burned many times reading some documentation and thinking I understood until I discovered the code has changed since and the documentation is now wrong.

I'm in favor of documentation. I write it. I get people pointing at what I've written as examples of what everybody should do. However it is a lot of work. I'm constantly looking things over to be sure it still makes sense. I often wonder if it is really worth it. I hope you follow my example and write documentation, but it better feel like a lot of work.

Re: Why do so many tools have JSON config files?

#56
post #7

> Why do so many tools have JSON config files‽ 1: Because JSON is a very easy serialization format to work with. I suspect these tools all have configuration classes / objects that are deserialized straight from the config file. 2: I suspect a lot of these tools are written in Javascript, and in Javascript JSON is very easy to work with.

JSON is probably the easiest format to work with regardless of language.

Pedantic response:

In C#, I find "binary serialization" much easier to program with than JSON.

Then again, the resulting blobs require specialized tooling to read, and they're very hard to work with in other programming languages.

---

But, jokes aside:

I find CSV is great for "rows" because it doesn't repeat field names for every object.

I really like XML when each tag is an object, and fields are attributes. Most people don't understand this and end up making a hug mess; and some serializers do this by default too. IMO, this is why JSON became much more popular.

Re: Why do so many tools have JSON config files?

#57
post #45

Earlier quoted context omitted.

It's readable, it's easy, it gets the job done. I don't think that's necessarily lazy, it's just efficient

I don't agree with "readable," though. For a simple set of key-values, yes. Once you get into complicated structures, other file formats express the semantics much better.

If you have a complex configuration you are doing it wrong... Spend some time thinking about you really want and turn it into a simple key-value setup. JSON should feel like it is overpowered and bloated for your needs. (I'd still use JSON because you can find a parser and editor that can handle it, but it should feel overpowered for your needs)

Re: Why do so many tools have JSON config files?

#58
post #7

> Why do so many tools have JSON config files‽ 1: Because JSON is a very easy serialization format to work with. I suspect these tools all have configuration classes / objects that are deserialized straight from the config file. 2: I suspect a lot of these tools are written in Javascript, and in Javascript JSON is very easy to work with.

JSON is probably the easiest format to work with regardless of language.

Mostly because it is so common (web) it doesn't matter what language you use there is a good maintained tool to read and write JSON.

Re: Why do so many tools have JSON config files?

#59

> Why do so many tools have JSON config files‽ Commenting why options have been set the way they have is just such a basic thing to want to do… Why do tech people have such an aversion to writing things down⁇ That's the whole post. First I don't know why this is posted on HN. Second I don't see how "JSON config" and "writing things down" are the two opposite options.

> That's the whole post. First I don't know why this is posted on HN. Second I don't see how "JSON config" and "writing things down" are the two opposite options.

The "writing things down bit" is in the context of commenting. I mean, it's literally in the same paragraph.

Re: Why do so many tools have JSON config files?

#60

TOML is a better format for configuration files IMO, if not for many reasons, primarily because TOML accepts comments. However, one annoying thing for TOML was the lack of schema, and the reliance on JSON Schema for that. Which I decided to tackle years ago when I started the TOML Schema project. In the past few months I leveraged code agents to take to the finish line and got something compelling: tomlschema.org

TOML is quite ridiculous. There are always an infinity of ways one can write the same values.

It should really define sections as something different from dot-separated identifier groups.

Post reply on HN