Read more about stringsbasic: "I'm a string. "You can quote me". Name\tJos\u00E9\nLocation\tSF."multiline_basic: """The quick brown \fox jumps over \the lazy dog."""literal: 'C:\Users\nodejs\templates'multiline_literal: '''The first newline istrimmed in raw strings.All other whitespaceis preserved.'''
Read more about numbers# Integersint1: +99int2: 1_000 # Separator!# Different formatshex: 0xDEADBEEF # Hexadecimaloct: 0o01234567 # Octalbin: 0b11010110 # Binary# Floatsflt1: +1.0flt2: 3.1415# Infinitysf1: inf # Positive infinitysf2: +inf # Positive infinitysf3: -inf # Negative infinity# Not a numbersf4: nan # Actual sNaN/qNaN encoding is implementation-specificsf5: +nan # Same as `nan`sf6: -nan # Valid, actual encoding is implementation-specific
Read more about objectsservices:nginx:host: "127.0.0.1"port: 80apache:virtual_host: "10.10.10.4"port: 81
Read more about arraysnumbers: [ 0.1, 0.2, 0.5, 1, 2, 5 ]# Nested and mixednumbers_and_strings: [ [ 1, 2 ], ["a", "b", "c"] ]# Array of objectstango_singers: [user1:name: "Carlos"surname: "Gardel"year_of_birth: 1890,user2:name: "Aníbal"surname: "Troilo"year_of_birth: 1914]
Read more about booleans# Just simple bool values. No magic, only one wayis_true: trueis_false: false
Read more about variables$my_host: "127.0.0.1"nginx:host: $my_hostport: 8080
Gura is simple and elegant
Gura was born from the need to have a configuration language that is human readable without falling into the unnecessary complexity of popular formats such as YAML.Read more in the full specs!
Differences with YAML
YAML offered a readable alternative to JSON or INI for a configuration file. While TOML was great for basic files because of its simplicity, YAML provided a readable solution when the complexity of the file grew. However, as the NOYAML manifesto argues, we should stop supporting that format. The reason? YAML is unnecessarily complex. We highlight main issues with YAML that Gura tries to solve.
- Multiple different ways to define a list and the elements inside it.
- 4 (!) ways to define a boolean.
- Boolean automatically inferred from strings (workarounds).
- Unnecessary unquoted strings that lead to float type inference problems.
- Serious security issues. Safe YAML attempts to address those, but only those.
- Increadibly long YAML specs for what is supposed to be a simple configuration language?
- Special data types such as Date or Datetime are defined in the spec, but the definition of their semantics is relegated to each specific implementation.
Differences with JSON
It's easy, JSON is and will be the fastest serialization language available. Gura is not meant for fast processing and/or machine-to-machine communication. When a readable, simple, and maintainable language is needed Gura becomes an excellent alternative.
Differences with TOML
The idea of Gura is not to replace TOML but to complement it when the complexity of the project warrants it. The use of TOML for files such as cargo.toml in the Rust programming language is an excellent example of matching the complexity of the language to that of the domain. However, when the level of nesting increases, TOML is very cumbersome since you must resort to repeating all the parent levels (using Dotted keys) every time you want to define a nested value. Furthermore, even TOML falls in some cases into the same complexity as YAML, with features such as:
- Multiple ways to specify keys.
- Empty keys.
- Special data types.
Gura combines the readability of YAML and a reduced version of its syntax with the (even more simplified) simplicity of TOML. It also brings in some features and characteristics exclusive to this language:
- 📦 Variables: Gura allows you to define variables of any type, even using environment variables, both as a flat value and as values inside a string. So you can compact and reuse the values you require.
- 📑 Imports: Gura defines a way to import different Gura files within the same file in order to modularize the configuration.
- 🚫 Standard errors: Gura defines the semantic errors that should be thrown in certain situations. This way you get an implementation-agnostic definition and the developer can get the same type of error regardless of the programming language he/she is using.
- 🥧 Gura is short and simple to learn and use since it follows the only one way to do it Python maxim.
- 🌈 Writing a parser or wrapper for Gura in a new language should be a short and simple as well.
Gura is simple, and its "one way of doing things" philosophy minimizes the possibility of error and its implementation complexity.
Gura has no implicit mechanisms that lead to bugs, it is strongly typed and bugs are standardized to make it a robust configuration language.
Gura retains the best aspects of well-known languages such as TOML and YAML to make user adoption a smooth and agile process.