5 ms·
I was skeptical too of this sentence, but then I realized that I have never used YAML for files that were more than ~200 lines long. What happens for huge confi
by ziotom78 6y ago
I was skeptical too of this sentence, but then I realized that I have never used YAML for files that were more than ~200 lines long. What happens for huge configuration files with lots of sub-trees?
(Comparison with indent-based program programming languages like Python and Haskell is not completely appropriate, because one typically avoids too many nesting levels when writing code. But in a large YAML file you might just need to go deep.)
- piaste 6y agoYAML anchors allow a basic level of reorganization and DRY within your file, not unlike functions in code. I'm sure that some people will scoff and point to anchors as exactly the kind of complexity a configuration format shouldn't have. But I've personally found them extremely useful and straightforward.
- chinigo 6y agoI'm working with a 12k-line YML file with lots of sub-trees right now, and let me tell you, it's a gigantic pain in the butt. If it were JSON, I could navigate within a subtree by selecting & searching the text between the `{}` delimiters. But instead, I have to gently scroll downwards, keeping a careful eye on the indentation, to see whether I've moved into the adjacent subtree.
- SahAssar 6y agoA 12kLOC YML sounds like it's always going to be a pain in the butt, but the specific problem you mention should be solvable by any editor that can collapse blocks, right? Most editors I've used (vscode, vim, phpstorm, intellij, even notepad++) have that feature built in or supplied by a pretty standard plugin.
- chinigo 6y agoYeah code folding works for the visual scrub, but it's the "search within" feature that's missing. An example of my common use case is digging through a Bosh manifest file for a resource with a particular name, then finding, say, the VM type associated with that resource. The name and vm_type fields may be separated by hundreds of lines (it's a machine-generated file that does not retain element order), but they're siblings of each other. In vim, I could land on the first { and then hit: v% (extend selection to matching delimiter) /\%Vvmtype: (to search for "vmtype:" within the selection). In IntelliJ I could similarly extend a selection between delimiters and then search within it. It's absolutely correct that this is a tooling problem. You could imagine a YML plugin for IntelliJ or vim smart enough to offer a motion for "select all the children of this block," but AFAICT no such tool exists.