What is YAML?
The full form of the YAML language can be different depending on whom you are asking it, mostly there are two full forms of this language and both of them are considered to be correct, the first one is yet another markup language while the other full form is YAML ain’t markup language. if you read the second full form of YAML, you will understand that the YAML is not a markup language which means that this language is used for data and not documents.
YAML syntax:
The syntax of the YAML programming language is very easy to understand and time efficient because it focuses on generating human-readable codes, here are some of the syntax rules for YAML:
Indentation: Just like python, the YAML language also heavily works on the basis of indentation in order to represent the nesting of the data as well as the hierarchy of it.
Note: In YAML, spaces are used for indentation rather than tabs.
Lists: YAML also allows us to create lists if we want, in YAML the lists are based on arrays which are a sequence of items. In YAML, each item which begins with a dash (‘-‘) along with a space is known as a list.
For example:
“`yaml
hobbies:
Catering
Cooking
Coding
“`
Key-Value pair: This contains data which is stored in key value pairs and are separated by a colon.
Example:
"name:Kishan Kaushik"
File Extension: YAML files are saved with a file format that ends with either “.yaml” or “.yml“
As you can see in the image below, the visual studio code provides the option to save the file as .yaml extension.
YAML Scalar syntax:
YAML scalar means that a simple value for any key, as we discussed later that the scalar can be float, Boolean, integer etc..The scalars are known to be the basic blocks that are required for writing the YAML language and they can be complex as well as simple depending on the requirements. The scalars can be written in various possible ways, let’s look at some of them as example:
1. Plain Style:
In the plain style of scalars in YAML, the scalars can be some simple strings which does not include any special characters or quotes, for example you can see:
key: value
2. Single-Quoted Style:
The scalars can also be closed in the single quotes this style is mostly used whenever you want to specify a string just the way it is without any special characters, for example:
key: 'value'
3. Double-Quoted Style:
Just like the single quotation marks we can also use the double quotations for the strings the only difference here is that the double-quoted string allows escape sequence to be interpreted, for example:
key: "value with\nnewline"
4. Flow Style:
Scalars can also be written in a more compact flow of style. this is suited for simple values and short values, for example:
key: { foo: bar, baz: 42 }
What Type of Language is YAML?
As we know the world of technology is filled with various modern and old languages which keep changing from time to time, each one of these languages serves a specific purpose and thus each language is used for performing certain tasks only. But when it comes to the programming language called YAML people sometimes get confused because they have trouble understanding what type of programming language YAML is, so in this article, we will understand what type of language the YAML programming language is.
Contact Us