Live data from Hacker News

Why do so many tools have JSON config files?

textlog.cc

71–78 of 78 posts

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

#71
post #6

Earlier quoted context omitted.

Reading and writing json is so much easier than reading or writing toml imo

I'd argue that for code, yes, JSON is vastly closer to computer structures. I think this is the real "why do so many tools have JSON config files": because it's just a literal notation, for basic data structures, that looks a lot like what many programming languages natively do, what their data structures natively are. The answer to the post is: it's mechanistic sympathy . For humans, I do find TOML to be a lot easie…

I find the toml structure impossible to follow as a human. It's like a complicated nested ini file. Asinine and terrible. I don't need a fancy editor (and I don't have one) to close my quotes and brackets. jq checks the syntax easily. On the other hand I have to crash my services to find out I nested shit wrong in toml because there's no structure

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

#73

Earlier quoted context omitted.

I do not use the ASN.1 schema format, and have not written a specification for how the new ASN.1X features would be used in the ASN.1 schema format, although someone who is interested to do so might be able to help to write such a thing. (An alternative might be to make up a different schema format for use with ASN.1X.) ASN.1X is mostly just a list of additional types, although there is also another serialization for…

A lot of that is already in ASN.1, for example for UTF-16 you've already got UTF-8 and given that even Microsoft have abandoned BMP strings I doubt any attempt to reintroduce it will get much traction, relative OIDs already exist, BCD strings are just constrained PrintableStrings and in any case UTF-8 won for all of the string types, Reference sounds like an EXTERNAL, OOB sounds like an ANY DEFINED BY, etc.

> for UTF-16 you've already got UTF-8 and given that even Microsoft have abandoned BMP strings I doubt any attempt to reintroduce it will get much traction

This is not reintroducing anything; the BMP type is already there, although its meaning is expanded (the existing BMP type is effectively a constrained subtype of UTF-16). Although most applications probably will not use UTF-16, it might sometimes be useful in some applications where it is more useful to store UTF-16 instead of converting to/from UTF-8.

> relative OIDs already exist

Yes, although I have given a standardized name and semantics to something that is allegedly already a common use (and is one that I often use in my own projects), which the official specification from ITU admits. It uses the existing OID and relative OID types (and the same type numbers as them), and is like a CHOICE between them (implementations may treat it as such).

> BCD strings are just constrained PrintableStrings

The abstract meaning matches that of constrained Visible (not Printable) strings, but the encoding is more compact.

> UTF-8 won for all of the string types

Although it is common (and some other formats don't support other string types), I disagree, and I think that one character set cannot be useful for all purposes, and furthermore that Unicode is not that good and has many problems.

> Reference sounds like an EXTERNAL, OOB sounds like an ANY DEFINED BY

I don't think so. It seem like different to me.

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

#74
post #51

Earlier quoted context omitted.

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.

"particular need". i also said json works everywhere. what was unclear?

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

#75
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.

I think there are many facets to readability. For example, YAML is frequently held up as much easier for humans to read than JSON, but even after many years of reading and writing YAML in various domains, no other format causes me anywhere near as much trouble.

With JSON, I can format the string as I feel makes sense for that specific data structure, while YAML forces me to into specific indentation patterns, and it still causes me to question every time whether the dashes in arrays should be indented or not. And since people frequently template YAML, the strict indentation has caused a bunch of issues for no good reason, including production outages (sure, shouldn't happen with good practices, but there are so many places without good practices!).

Because JSON syntax generally has only one way to represent each data type and almost every data type uses explicit start and end signifiers (except floats and bools, both of which are short and clearly stand out), it's easy to know what the context of every character is both while reading linearly, and when jumping to specific points. Meanwhile YAML has multiple ways to express almost anything, and frequently the only way to tell the current context is to read ahead before jumping back. This is especially terrible for strings due to optional delineation, because almost every bare text could be a keyword (as demonstrated by the Norway problem).

I know this is not most people's experience, but that's because readability is subjective.

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

#76
post #71

Earlier quoted context omitted.

I'd argue that for code, yes, JSON is vastly closer to computer structures. I think this is the real "why do so many tools have JSON config files": because it's just a literal notation, for basic data structures, that looks a lot like what many programming languages natively do, what their data structures natively are. The answer to the post is: it's mechanistic sympathy . For humans, I do find TOML to be a lot easie…

I find the toml structure impossible to follow as a human. It's like a complicated nested ini file. Asinine and terrible. I don't need a fancy editor (and I don't have one) to close my quotes and brackets. jq checks the syntax easily. On the other hand I have to crash my services to find out I nested shit wrong in toml because there's no structure

What are your thoughts on ini? My perspective is that >9/10 toml's are just ini files, straight up. The nesting seems rare, and rarely confusing to me.

I obviously disagree about the ease of json editing. jq tells me errors, sure. But formats where we don't need bespoke tooling, where notepad.exe work fine, are I think probably what config files should be more like.

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

#77
post #4

Somewhat off topic, but Oracle database connection strings seem to be a form of Lisp. It makes me wonder why they would choose that.

I looked them up, and they’re not lisp (or s-expressions)

    SERVER=(DESCRIPTION (ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;

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

#78
post #71

Earlier quoted context omitted.

I find the toml structure impossible to follow as a human. It's like a complicated nested ini file. Asinine and terrible. I don't need a fancy editor (and I don't have one) to close my quotes and brackets. jq checks the syntax easily. On the other hand I have to crash my services to find out I nested shit wrong in toml because there's no structure

What are your thoughts on ini? My perspective is that >9/10 toml's are just ini files, straight up. The nesting seems rare, and rarely confusing to me. I obviously disagree about the ease of json editing. jq tells me errors, sure. But formats where we don't need bespoke tooling, where notepad.exe work fine, are I think probably what config files should be more like.

My only experience with toml is complicated nested ones because I'm sure that the maintainers outgrew whatever was simple. Off the top my head it's just containerd config. Yaml probably a better choice than json and ini is fine if it gets the job done, but it's it really more than .env? My opinion is the env should do a lot of lifting anyway. I'm thinking there's always "tooling." My toml might syntax but be logically incorrect all the formats have that problem and linting doesn't stop at json. Like changing my containerd config I don't really know if it took or not
Post reply on HN