UCG is a universal grammar for configuration.
That's a good question. The world certainly doesn't need another serialization
format for configuration values. We probably haven't really needed another
serialization format since ini
files and xml
. But now that we do have so
many to choose from people are choosing them right and left.
Chances are if you manage more than 2 systems in your job then you have at least 2 different serialization formats for their configuration. You probably also have parts of that configuration that are shared between multiple systems and need to be kept in sync between those different formats.
You might also have standard configs for vm based languages or deployment targets like kubernetes. You also probably have a configuration management system and it probably has some form of templating support to meet all of those needs. UCG is meant to solve the problems that the templating engine introduces.
Templates can be difficult to manage without introducing hard to see errors in the serialization format they are generating. Most templating engines aren't aware of the format they are templating. They usually end up being an ad-hoc programming language in their own right but without any way to enforce invariants or protect the template writer from creating bad configs. UCG attempts to solve this problem by giving you a real programming language that also generates the config format you need natively and safely.
UCG's goal is not to define a configuration format like JSON, YAML, or TOML. It is not intended to replace the other serialization formats. Instead it is intended to provide a common grammar for generating those formats. Currently UCG is able to compile into a number of formats including:
UCG is not a templating language. It is a compiler whose targets are specific
serialization formats. As such it doesn't output invalid formats in, for
example, json
or yaml
. It allows you to check configurations against
schemas. It lets you use shared logic when assembling the datastructures that
your config format.
UCG allows you to use one common grammar to generate configuation values for any applications that use one of provided serialization formats while also allowing you to easily share common configuration values like hostnames, jvm settings, and database settings.
UCG is designed to make configuration as code a first class citizen of your deployment strategy.
When I started UCG I was unaware of some other attempts at this that came before. If you find UCG intriguing you might be interested in these other projects with similar goals.
UCG | JSonnet | Dhall | |
---|---|---|---|
Variables | x | x | x |
Conditionals | x | x | x |
Functions | x | x | x |
Modules/Classes | x | x | x |
Imports | x | x | x |
Std Lib | Minimal | x | Prelude |
Type Safety | Inferred types and schema validation | Unknown | Inferred types |
Guaranteed to terminate | No | No | Yes |