4 ms·
.ini files are the only good option. I did a thing that used JSON for config years ago when I was young and stupid (60). Terrible choice. Someone in this threa
by tqwhite 8y ago
.ini files are the only good option.
I did a thing that used JSON for config years ago when I was young and stupid (60). Terrible choice. Someone in this thread said that config files need the amenities of source code. I agree. However it also needs to be readily machine generated in case your system is successful enough to support a UI for configuration.
.ini hits the sweet spot for me. I can edit it reliably. It's extensible in every way I've ever wanted.
I looked at TOML, mentioned below. I would like the array syntax but when I saw the Wikipedia article's example including something with quotation marks I realized that complicating it with array syntax means that you hop down the slippery slope to having semantic cruft to distinguish the types.
For .ini, everything is a string, period. You always know what you have. No debugging.
In fact, I wrote myself a .ini interpreter that does some obvious stuff to make it useful in Javascript. Case-insensitive interpretation of true/false. Things that can be a number become one.
But then, slippery slopes galore. I added hinting to let me convert objects with number property names to arrays. Now I spend my entire life realizing that I didn't add the hint for this recently, quickly added case.
I'd be better off just always converting it where I need to use it.
It's my opinion that changing anything about the .ini is always premature optimization.