Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is so easy to complain about something, but seriously: what are the alternatives for human readable config files?


In 2008, before many of the options for configuration that are available now had been created, I came up with a hierarchical configuration language [0] to use in my Python code. More recently, I had a look at some of the newer options available (JSON5, HJSON, HOCON, SANE and TOML), but still find them wanting in various ways. The latest iteration of my take on it [1] is now available in multiple environments (Python, the JVM, .NET, Go, Rust, D and JavaScript). I would welcome any critique from the HN community.

[0] https://wiki.python.org/moin/HierConfig

[1] https://docs.red-dove.com/cfg/index.html


I really like TOML. It's very similar to old-school INI files except it has a standard and parsers in quite a few languages. It does has its own downsides (while the concept of tables is quite useful, it can be a bit tricky to understand when you first see it). But it's one of the least-bad "modern" configuration formats I've seen.



For a scripting language, how about the language itself?


This is what I do whenever possible. And bonus if your scripting language is statically typed. My projects use TypeScript configurations, with the `config` import statically typed and each configuration file checked against those types. It's a great way to ensure you don't miss a config change for an environment you're not working on at the time.


Many reasons to prefer a static declarative config over a dynamic imperative one. Sometimes the latter makes more sense, but there is very much a need for the niche YAML tries to fill


submission about exactly that: https://news.ycombinator.com/item?id=22787332


Turing complete configuration is a no-no.


Why?


I want my configuration to be guaranteed to halt for one, I don’t want my configuration to have the ability to open sockets, I don’t want configuration to import business logic or 3rd party modules, etc.


JSON is perfectly readable in my opinion.


Doesn't the article go over that?


Where? I only see in "conclusions" that StrictYAML is recommended, but this is only about the implementation not the format itself.

TOML is mentioned but I do not see wide adoption, e.g. no up-to-date Java or similar implementation. (https://github.com/toml-lang/toml/wiki#implementations)

Additionally I think TOML is more verbose compared to YAML but avoids the indentation ugliness.


If you're in the Java world, HOCON is pretty neat.

https://github.com/lightbend/config




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: