by swid · 4y ago · 0 comments
I will probably use YAML for the foreseeable future instead of creating new languages or interfaces. Think like how CircleCI configuration works. Essentially it is a DSL, but implemented in a format that is widely used and easy to write and parse.
I do have issues with how yaml deals with strings, but it’s the best popular format I think I can use, and seems appropriate for developers.
YAML is extremely limited and a very bad choice for DSLs. CircleCI got it wrong. Their configuration files are extremely verbose and hard to abstract over - you have to use orbs and those come with a lot a of flaws. I'm a user for many years now and it's diminishing my productivity.
The solution isn't so hard - even Jenkins got it right. Use a regular programming language (maybe the one of your choice or one that is well suited for DSLs like Scala or Clojure) and then just expect your developers to build a datastructure in that language. This datastructure is your DSL.
Your users get a lot of stuff for free, including fully fledged code-completion and compile-time safety (if you use a statically typed language). It will also be easy to abstract over commong logic and even share it if the language has any kind of module/library system which almost every language has.
FWIW, the most recent thing I built that could be considered a DSL is how we define roles where I work. It’s a lot like IAM policies. I wouldn’t want to run arbitrary code when parsing these documents, and I think yaml suits it well.
Another example where, aspects like linking/checking etc are being worked around Yaml limitations are in K8s CDKs.