5 ms·
INI, JSON and YAML all have problems. None of them are serious enough for me to consider this for a small project with one or two config files required. Good to
by jokull 14y ago
INI, JSON and YAML all have problems. None of them are serious enough for me to consider this for a small project with one or two config files required. Good to be able to point to a config file syntax done right though.
- dasil003 14y agoBut the combination of Tom's reputation and the nightmare security situation currently unfolding with YAML means this project has a very high likelihood of becoming defacto standard in the Ruby community. The thought of being able to get rid of YAML from my code base entirely is an appealing end unto itself. Security aside, YAML is just ridiculously complex and error-prone. Can you tell at a glance what is wrong with this YAML snippet: scandinavia: SE: Sweden NO: Norway FI: Finland
- networked 14y agoI'm not familiar enough with YAML to see the problem at a glance but parsing the snippet with an online parser [1] suggests that unless you put quotation marks around "NO" it gets parsed into a boolean False. Looks precarious, especially since not requiring strings to be quoted is kind of a selling point of YAML. [1] https://yaml-online-parser.appspot.com/ https://yaml-online-parser.appspot.com/
- dasil003 14y agoThat's it, but you cheated :) I had to spend half an hour debugging a bizarre side effect of that parsing to pinpoint the problem.
- antihero 14y agoThat is utterly stupid isn't it, how could the designers of YAML count a capital "NO" as a key as False. Wow. Edit, holy fuck all these are booleans: y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF
- account_taken 14y agoDo tell about the problems with JSON for use as a configuration object? Almost every language has a library that can parse JSON.
- jokull 14y agoIt’s hard to author by hand. Ever added a comma after the last element in a list? It’s not very forgiving.
- stormbrew 14y agoThis is actually one of the worst things about it to me, other than the lack of comments. A language that has comma-separated lists and doesn't allow trailing commas on the list as a whole is frustrating to use in a version controlled context because adding an item requires modifying the item before, which leads to more (and less obviously solvable) merge conflicts.
- GhotiFish 14y agoI've seen a style of list initialization that sort of addresses this issue. I like it, but I don't see it used very often. Darn you standards! kittyBreeds = ["Himalayan" ,"Bengal" ,"Siamese" ,"Burmese" ,"Cornish Rex" //rawr ,"LaPerm" ,"Manx" //This is not a real cat! >:( // ,"lolcat" ,"Munchkin" ,"Ocicat" ]; In this way the issue with the commas is relegated to the first element, rather than the last. Since appending is more common, this seems a better style.
- stormbrew 14y agoInteresting approach. This strikes me as kind of like the classic "put the constant on the left" advice in C/C++ that, no matter how many people agree it's a good idea, no one ever does because the cognitive effort of understanding it is high enough to diminish the correctness benefit. In other words, you know you're just gonna end up with this in your code after a few months: kittyBreeds = ["Himalayan", ,"Bengal", "Siamese", "Cornish Rex", ,"Manx"] and not only is it now even worse for changing lines (correcting it and adding another will be -1+3 instead of just -1+2, the optimal +1 a distant memory), but it's just plain a mess and probably people don't know why they need to do it.
- luser001 14y agoYou seem picky. :) But check out libconfig. Maybe it'll work for you.