Skip to content

Instantly share code, notes, and snippets.

@MRobertEvers
Last active February 25, 2021 15:42
Show Gist options
  • Save MRobertEvers/a617c642242d0fdabb598ae4fbad3cbf to your computer and use it in GitHub Desktop.
Save MRobertEvers/a617c642242d0fdabb598ae4fbad3cbf to your computer and use it in GitHub Desktop.
Program Config

Program Config as Code

I thought it was weird that some software/libs/frameworks take executable code as config, but I recently read a blog talking about DSLs and config files with conditionals and statements.

It talked about how certain programs provide a DSL in their yaml configs (obviously in-house for each program). These DSLs are not portable because every system rolls their own.

Article here, https://blog.earthly.dev/intercal-yaml-and-other-horrible-programming-languages/

For example, Webpack can take config as an executable javascript file. I always thought that was weird (not bad), but I think I much prefer it to a DSL embedded in yaml or JSON.

I really like the config flow as

function genConfig(config) {
  if (blah)
    config.provideX()
    
  config.sysEnabled = true
  
  // etc...
}

where the function genConfig is called by the program at startup. It's readable** and provides all the power of the programming language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment