3 ms·
> This is easily solvable by tools. Maybe, but I want it to work with standard tools. Most editors seem to arbitrarily jump back a couple of indentation levels
by Tainnor 6y ago
> This is easily solvable by tools.
Maybe, but I want it to work with standard tools. Most editors seem to arbitrarily jump back a couple of indentation levels e.g. if you add newlines somewhere. This obviously doesn't happen with JSON, since the editor won't have to guess whether you wanted to de-dent or not, it's all explicit. And I'm not making this problem up, it's literally a problem almost every time I have to edit some larger YAML file.
I'm not a fan of whitespace sensitivity in programming languages either, but at least Python etc. make a habit of discouraging 15 layers of indentation.
> Please don't. JSON, YAML and XML config files can be easily and safely manipulated in all programming languages, for custom DSLs people end up using brittle regexps. It's not much better than putting config consts in a code file.
What? Why would you parse a DSL with regex? I'm not saying people should write crappy DSLs. You can either write your own proper parser or you just use an embedded DSL, since there are multiple languages out there who are quite good at providing DSL support. The bonus is that it's often even type-safe, without having to be as mind-numbingly obtuse as XML.
- Pako 6y agoOn the note of type safety I can always suggest people to take a look at Dhall. https://dhall-lang.org https://dhall-lang.org
- Tainnor 6y agoYes, this is something I've wanted to check out for a while now, I just don't think I could convince other people on any team to look at it. :D
- thinkharderdev 6y agoI've had the same experience. Different editors and IDEs seem to handle YAML in wildly different ways. If you copy/paste a YAML stanza into a different document there is no telling how the editor is going to indent it. And trying to fix it can be something of a nightmare, especially when the editor indents different lines in the pasted text differently.
- kanox 6y ago> What? Why would you parse a DSL with regex? Let's say I want to process a nginx or apache config file programmatically to change a flag. Am I going to parse the full syntax? No, I'm going to hack something together with regexps.