91 points · by vishr · 10y ago · 57 comments
Ok, it might be better than Apache's mongrel mix of not-quite and SGML/XML dialect -- but I'd much rather see something like YAML than having to write JSON by hand. I suppose I should just write a compiler (or use one, I'm sure simple YAML maps pretty well 1:1 to simple JSON).
It has all the benefits of JSON and YAML, but it's not so complicated to parse and does not depend on indentation.
It also supports including multiple config files that merge into one big config. Globbing config files in a directory would be easy.
As an asise, the author of Ozzo-Config is Qiang Xue. He founded the Yii and Yii2 PHP frameworks. Golang code quality in his Ozzo libraries is very good.
Is YAML one of those things that proper professional programmers need but us amateurs can botch our way around?
Yes - I know that some JSON parsers will allow comments and strip them, but IMHO you shouldn't rely on this, and lots of editors will complain if they encounter any non-standard JSON.
If the names/values are chosen well their purpose will be self evident.
I think TOML strikes a good ballance between simplicity and features for config files. It ends up being easy to read and write.
https://github.com/crdoconnor/strictyaml
IMO TOML is syntactically messy, especially when dealing with hierarchical data, and a whole new config format to deal with the fact that YAML has too many features is somewhat unnecessary.
TOML is really nice for configuration files.
JSON for config is a bad, bad idea - especially if your config will get large.
> Is YAML one of those things that proper professional programmers need but us amateurs can botch our way around?
I really don't understand this attitude. If you already call `json.load(some_string)', there's no difference to change to `yaml.load(some_string)' and go with that. YAML data model is similar to JSON.
JSON is a format mainly for machines, and is somewhat readable for humans. YAML is the reverse: it's mainly for humans, but can be processed by machines.
Actually YAML should be easier to amateurs than to professionals. Pros have tools that deal properly with XML, JSON is a lesser problem.
Spot the typo!
If you think this is stupid because surely everyone uses an editor with automatic scope highlighting etc, I don't think that is the case when you are remotely editing config files via SSH.
It's nice if it's easy to write - but the real test is read, comprehend, modify.
JSON merges the worst and most redundant parts of C and lisp.
I prefer yaml for deep nesting over toml, though. But whatever the config syntax, comment-preserving parsing would be very nice for config files.
Why not use a real programming language as the "configuration file"? That way, you can install callbacks, etcetera.
My favorite configuration file type?
# Comment
key = value
Trying to do more in the configuration file ends up causing more headaches than it solves. Commenting each option means you don't have to flip through the manual to figure out how to get the stupid thing to run.There is some argument for the:
[section]
# Comment
key = value
Style syntax, but I find that for the vast majority of cases making those namespaces is an unnecessary complication. If you have multiple copies of the same option (like multiple VPN endpoints for example), it's almost always a better idea to just split each one up into its own file in a subdirectory instead of trying to stuff all of the info into a single configuration file. People who want to automate stuff later will thank you.There are libraries to read and write those formats just as easily as JSON or XML or anything else. In fact they're usually easier to use because they don't have to worry about hierarchies or namespaces or any of that nonsense.
Some more thoughts on the subject: http://stackoverflow.com/questions/648246/at-what-point-does...
There seem to be a lot of "router" or "middleware" benchmarks nowadays, but from my experience that performance difference is negligible compared to what a different protocol or IO stack implementation can do, e.g. using blocking IO vs. using async IO, buffering and write strategies, etc. If both use net/http I wouldn't expect any difference that really matters in real applications. fasthttp seems to make a difference, but as far as I can read from the documentation it isn't used in Echo v3.