4 ms·
People don't necessarily hate XML, but man do we hate tags. One huge feature of YAML is its clever use of whitespace to eliminate a lot of cruft from the syntax
by yen223 12y ago
People don't necessarily hate XML, but man do we hate tags. One huge feature of YAML is its clever use of whitespace to eliminate a lot of cruft from the syntax.
That said, I'm starting to warm to the fact that Django uses straight Python for its settings. If you're going to use a Turing-complete language to write your config file, might as well use a familiar one.
- colechristensen 12y agoI hate XML. It is a basket of good intentions poorly implemented.
- yen223 12y agoAmen to that. I actually like the idea behind XSD - I have encountered situations where a "strongly-typed" configuration file would have made a lot of sense. Only problem is that the kinda-like-XML-but-not-really format of XSD is so clunky it becomes a second source of frustration.
- sanderjd 12y agoYes! One of my little frustrations with Rails is that most configuration is done in Ruby, but then every now and again you're supposed to configure something with YAML, and then even weirder, some YAML files are actually implicitly interpreted as erb. It's weird and I'm not sure what the point is.
- yen223 12y agoThe idea is like what crdoconnor mentioned - it's good design to strictly separate 'data' from 'code', and most configurations are 'data'. Unfortunately, in practice there are plenty of times when a small loop or a conditional would greatly enhance DRY in config files.
- crdoconnor 12y agoI hate XML. It's unnecessarily complicated, it breaks easily and it's verbose. YAML is kind of sucky as a data transfer format (chopped up YAML is still valid which leads to all kinds of screwed up behavior), but its mirror equivalent JSON is good for that. Equally, JSON sucks for declarative configuration but YAML really shines. Django's settings file is also one of the thornier bits of django. I'm not sure if should necessarily have become declarative, but making it a monolithic python file causes a lot of headaches with integrating modules, state changes, etc. The fact that you can often move a bit of config from one end of the file to the other and change the behavior completely is a bit screwed up. I think it would work better if it were a bit more ansible-y.
- yen223 12y agoI never did like using JSON as a configuration format (I'm looking at you, Sublime Text). But it's still miles ahead of using XML as a config format. I can see where you're coming from regarding Django's settings file. Lord knows how many hours I've wasted hunting down stray configurations thanks to frameworks which abuse inheritance for its settings config (I'm looking at you, Mezzanine). Still, the fact that it is Python, and can therefore be debugged like any other Python script instead of obeying its own special syntax, is a plus in my books.
- crdoconnor 12y agoI was actually thinking of mezzanine when I wrote that (and django-cms is worse!). Both packages gave me a real headache while setting up settings.py. There was no clean separation between code and declarative configuration.