What are technologies like XML, JSON, and YAML classified as?
I already looked at
- Query Language
- Data-structured Language
But neither appeared accurate… None of them are really meant for creating queries. And JSON isn’t a language, so DSL doesn’t apply.
I see those technologies used a lot with configuration files and passing data between web services and web clients. Is there a general category or term to describe them?
3
Declarative Languages
Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions exist that attempt to give the term a definition other than simply contrasting it with imperative programming.
For example:
- A program that describes what computation should be performed and not how to compute it
- Any programming language that lacks side effects (or more specifically, is referentially transparent)
- A language with a clear correspondence to mathematical logic.[4]
Source: Wikipedia
Declarative languages are intended to express what — not how — a program should accomplish.
Web based design (ie HTML/CSS) are both good examples. They describe instructions for the browser on how a webpage should be structured and represented visually but possess no ability of their own to produce the output. How browsers/clients consume their code can be wildly different as long as the output produces the intended result as per the W3C/WHATWG specify.
Serialization/deserialization and DSLs (Domain Specific Languages) like SQL are another good example. They are designed and intended to follow a strict standard of functionality regardless of what language/platform they are run on.
The key to a good declarative language is that it does a good job of describing a data/process in simple, finite terms with little room for subjective variation.
The key to a good implementation of a system that consumes/produces declarative code is consistency with any/all other systems that consume it.
Markdown is a good example of a useful declarative language that suffers from a poor initial specification/design. Markdown evolved organically in the wild because of its usefulness. Unfortunately, in the absence of a well defined specification, there are now a lot of different variations when it comes to implementation. Many notable developers have taken the standardization of Markdown as a personal mission but — at best — an official standard will only be accepted through the slow/painful process of survival of the fittest. Even then, variations will always exist to some extent.
Technically, there is a formal system for classifying languages called the Chomsky Hierarchy. It describes is mathematical terms the different types of programming grammars based on how they’re parsed.
XML, JSON, and YAML generally fall under context-free or context-sensitive languages depending on how they’re used.
Considering usage, I think Declarative is a better term to describe what you’re looking for.
7
XML = “eXstensible Markup Language”
YAML = “YAML Ain’t Markup Language” (Though it was originally “Yet Another Markup Language”.)
Though in truth people think of them more like data formats (which JSON is) rather than languages partly because people assume “Language” == “Turing Complete”.
3
Despite having the word language in them, I would not consider them programming languages, but rather data formats. I know that XML has been used as the format for some DSLs, probably likewise for YML.
A language does not have to be Turing complete to be a programming language, but it does need to be active — without exceeding the standard definition, these “languages” do not include meanings that act upon the data.
XSLT is a language that uses XML, but XSLT is more than just XML –it attaches meanings beyond the DTD it attaches meaning that includes actions to be taken on the data. While not mentioned, HTML, like XSLT, is a programming language. XSLT is Turing complete while HTML is not. HTML is a declarative language — it says to emphasis some content or that some content is a heading or to be bolded.
The whole point of XML is for it to NOT include actions — it is data. What that data means, whether it is a todo list or a program for calculating Fibonacci sequences is inconsequential — XML is data and the related DTD describes its format, the MEANING of the data is determined by the consumer. XML does this because HTML mixed the data and the meaning, which proved somewhat, uhm, fragile.
In short, just accept it as sloppy terminology, and move on.