5 ms·
Really wish people would just bite the bullet and do configuration as code instead of trying to make all these config petlangs.
by Defletter 1y ago
Really wish people would just bite the bullet and do configuration as code instead of trying to make all these config petlangs.
- patrickmay 1y agoExactly. Emacs Lisp is an existence proof that this can be done well.
- taeric 1y agoYou beat me to it! And for those that haven't taken a look at it, the "customize" menu and everything it supports is silly impressive. And it just writes out the results out, like a boss.* * Obviously, it has a lot of "don't edit below this line" complexity to it. But that doesn't change that it is right there.
- skydhash 1y agoMy preference is towards simpler formats like: option value Easy to edit and manipulate. JSON and YAML is always a nightmare if it's user facing. As for ansible, I'd love to see some scheme/lisp variants.
- mrheosuper 1y agothen how you distinguish between string "52" and number 52 ? Keep adding more edge cases and you have something resembles JSON
- skydhash 1y agoWhy do you need to differentiate between the two as an input? It’s config, not random data. If you have email test@example.com logo-size 100 background #adadaf modules auth modules db modules files The only reason to have special token here is if you multiple line values. Types are not a concern.
- bandie91 1y agoi don't. and neither my perl-based softwares. there should not be the possibility whereas a given parameter can have both string or a numeric value too at the configuration level which the user interfaces with - as of the "real-world analogy" programming paradigm suggests. json and stuff still do have their place but in a lower, machine-to-machine layer.
- horsawlarway 1y agoI appreciate that the ts/js ecosystem seems to be moving in this general direction. Lots of config.json is being replaced by the nicer config.ts.
- nikeee 1y agoI really dislike it when a turing-complete language is used for configuration. It almost always breaks every possibility to programmatically process or analyze the config. You can't just JSON.parse the file and check it. Also I've been in projects where I had to debug the config multiple levels deep, tracking side-effects someone made in some constructor trying to DRY out the code. We already have these issues in the application itself. Lets not also do that in configurations.
- crdrost 1y agoThis is what's nice about Pkl, you define a schema as a Pkl file, you define a value of that schema as a Pkl file that imports the schema, `pkl eval my file.pkl` will do the type check and output yaml for visual inspection or programmatic processing, but keeping it to one file per module means that I almost never obsessively D-R-Y my Pkl configs. Actually that's not the biggest benefit (which is tests for schemas) but it's nice to have the “.ts” file actually log the actual config as JSON and then the app consumes it as JSON, rather than importing the .ts file and all its dependencies and having weird things like “this configuration property expects a lambda.”
- echelon 1y agoThat's why Starlark exists. You need something between JSON/YAML and Python/JavaScript. A config language makes the possibility space small. It also makes it deterministic for CI and repeatable builds. It also makes it parallelizable and cacheable. Don't use your language for config. People will abuse it. Use a config language like Starlark or RCL.
- skydhash 1y agoI still have to see a JS project where the config for each tool could not be something simple like `.toolrc`. We could have some markers to delineate plugins config. Instead, there’s a another software in the configuration of sample projects, instead of just using good code organization and sensible conventions.
- frou_dh 1y agoWhen Python projects used that approach (setup.py files) that meant to just know what a package's dependencies were, arbitrary code had to be run. Now it's pyproject.toml
- nickelpro 1y agopyproject.toml calls into a build backend which is... Python. It is good to have a simple, declarative entry point to the build system which records declarative elements of the build. The non-declarative elements of the system are configuration-as-code.
- lenkite 1y agoYes, though languages need to develop and provide restricted execution modes for "configuration as code" for security enforcement.
- tekbruh9000 1y agoThis year I started using an SQLite file specifically for config values Have used everything from Json to Cue and in-between. Tired of the context switch. Need to use SQL anyway. Fewer dependencies overall required.
- mrmrcoleman 1y agoCurious - how do you version the config?
- stirfish 1y agoI'm guessing they version a SQL file
- tekbruh9000 1y agoYes. Git log is a handy thing for versioning. I never relied on it for developer notes. Just arguing semantics in those cases.
- theknarf 1y agoConfig as code suffers from two big problems: - Turing completeness means that you have to deal with the halting problem, meaning you can't statically ensure that a program ever completes. This is really shit when dealing with config, one buggy while loop or infinite recursive function and stuff just grinds to a halt with no good way of debugging it. Having this problem at the config level might mean that your program never even gets to properly start up, so you never get to setup the logging / otel or whatever you usually use to catch those problems. - Normal programming languages have side effects and are therefor insecure! They can usually read and write files anywhere, open sockets, send traffic over the internet, etc. These are all properties you don't want of a config language! Especially if you can import code from other modules, a single import statement in a "config file" is now a huge security risk! This is why "npm" keeps having security nightmares again and again and again. So what you want from a config language is not the same thing as from a programming language, you want as much power as you can get without "Turing completeness" and without any "side effects". That's the reason we have stuff like HCL and whatever the article used as an example.