3 ms·
Embedding one language in another isn't an uncommon pattern. Regular expressions and SQL in my Python JavaScript and CSS in my HTML Sed / Awk / etc in my Bas
by simonw 6y ago
Embedding one language in another isn't an uncommon pattern.
Regular expressions and SQL in my Python
JavaScript and CSS in my HTML
Sed / Awk / etc in my Bash
Embedding a custom conditional syntax in YAML feels pretty tame in comparison to those.
- toomanybeersies 6y agoExcept that every tool that uses YAML config files has its own unique language for embedding conditional logic, with enough similarities to be familiar, but enough differences and idiosyncrasies to be frustrating, requiring you to re-read the documentation every time you need to write anything as it's impossible to remember the half-dozen different dialects of "YAML logic". I also encounter this every time I need to write a non-trivial regular expression, I can never remember the differences in regex syntax for sed, ruby, JS, etc. etc.
- baq 6y agovery good points - i disagree on nuances: - Python provides a grammar for its implementation of regex (note that some langauges make regexes first-class syntax - perl, JS) - JS has a defined standard cross-platform cross-browser syntax, ditto CSS (yes i know it's not 100% true) - sed/awk in bash - i agree - but there's a bigger POSIX standard which defines all of it the problem with yaml is that it isn't even a language, it's just a way to describe a recursive tree/list data structure. everybody defines their own language pretending to standardize on yaml where in fact the syntax similarities are doing little more than mislead you what product you're creating documents for.
- marcosdumay 6y agoWhat benefit is the YAML giving you? On your examples, one mixes an specialized language into a general one. The general language is much better for most tasks, but once in a while there is a problem that fits the specialized one. But YAML isn't much better than a general language for defining data structures (what config files are), and isn't general in any way.