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

Yes that's a common problem with config languages. They're torn between competing priorities:

1. Fast to parse with a small engine, good error messages, safe to evaluate.

2. Powerful, can express config with arbitrary logic.

In Conveyor we try an alternative approach. The config is HOCON, which is a superset of JSON syntax designed for human readability/writability/convenience first and foremost, so it's got a very nice and clean feel to it. You can see an example here:

https://github.com/hydraulic-software/github-desktop/blob/co...

It can be parsed with a normal-sized config library and the errors you get are reasonable.

But then what if you hit the limits of what it can express? We added support for "hashbang includes":

    include "#!script.js"
You can embed arbitrary commands in the config which are executed when found unless the app is running in untrusted mode. The script is expected to produce more config on stdout, which is then included. This lets you encode only the minimal needed logic using a full programming language, whilst the rest stays declarative.


In case you want a fresh opinion, every time I stumble upon a config like this, I wish it was just a .json, .js, .py, heck even .pl or .php file rather than that.

Why. It’s unclear what’s the syntactic structure of it at a glance. Yes, in stricter languages there’s more of /[()[\]{}"'`,;]/, but also I know for sure what’s a literal, what’s an identifier, what’s a key, what’s a number or a date. The whole structure and ordering is obvious.

Same issue I have with nginx, terraform and other ad-hoc half-languages half-formats half-templates. The worst part is that you have to hack them once a year, but it never “sinks in” for good even if you read the docs.


Thanks. HOCON is a superset of JSON so you can write JSON if you like. There's also a spec:

https://conveyor.hydraulic.dev/7.2/configs/hocon-spec/

You can also convert HOCON to JSON and back. I find it a lot easier to work with configs when you can get rid of superfluous syntax, can use comments, substitutions, include files etc. But you don't have to use those.




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

Search: