The difference between configuration formats, configuration languages, data formats, and programming languages
There is a lot of confusion out there about what different file formats are and how they are intended to be used. Having used a lot of them over the years, I think I can explain their differences, and when and how to use them.
A data format is a file format for encoding data. Typically the format is structured to make it easier for machine interpreting & processing. It consists of a structure (or schema) of one or more data types, and may allow for specific data to be included which will trigger specific kinds of data processing.
A programming language is a formal language comprising a set of instructions.
These are programming languages that are used for many purposes (XML, UML, BASIC, C, Java, Python). They can be used for a wide variety of tasks and are not limited in their use cases.
These are programming languages designed for a specific application or problem domain.
A configuration format is a data format designed to assist in configuring an application or service. The format does not create new functionality, but merely instructs a program on what functionality should or should not be used, or what values should be used for various functions.
A configuration language is a domain-specific programming language designed for a specific application or problem domain. They provide a formal language comprising a set of instructions in order to create configuration for an application or service.
Examples of configuration languages include Apache configuration (https://httpd.apache.org/docs/2.4/sections.html), Hashicorp Configuration Language (https://github.com/hashicorp/hcl), Puppet configuration language (https://puppet.com/docs/puppet/5.5/lang_summary.html) (https://puppet.com/blog/why-puppet-has-its-own-configuration-language/).
Some configuration languages claim to be "declarative", while others do not ("imperative"). What does this mean?
A declarative language is a language for declarative programming. Declarative programs describe their desired results without explicitly listing commands or steps that must be performed.
Imperative languages list a specific set of steps or actions to perform in order to get to a desired end state.
Most configuration is only intended to give provide input to a function. The function takes this input and determines what actions to take and what the end state or output should be. As most configuration is not describing a specific end state, nor giving a list of instructions to perform to reach and end state, configuration is typically neither declarative nor imperative.
Some configuration languages are advertised as "declarative". But usually they are complicated enough languages that they can be used in a way that does not describe a desired end state, or that provides an order of instructions that must be followed to reach the desired end state. Thus, whether something is declarative or imperative should be evaluated on a case by case basis.
Some applications use configuration that blurs the line between a data format and language, and it can be hard to tell which is which.
For example:
- Ansible uses both a configuration file in an INI configuration format, and a language called a Playbook which is encoded in a YAML data format.