5

What are technologies like XML, JSON, and YAML classified as?

I already looked at

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
    On wikipedia, they are all under [Category:Data serialization formats](http://en.wikipedia.org/wiki/Category:Data_serialization_formats) –  Dec 15 '14 at 00:50
  • @MichaelT Since when is YAML used for serialization? I've only ever seen it used for configuration. – Evan Plaice Dec 15 '14 at 18:12
  • @EvanPlaice the configuration file could be thought of as a sterilization too. You could easily create a configuration object that the YAML configures to. A glance at the [yaml](http://www.ruby-doc.org/stdlib-2.0/libdoc/yaml/rdoc/YAML.html) gem for ruby starts out with "This module provides a Ruby interface for data serialization in YAML format." –  Dec 15 '14 at 23:23

3 Answers3

8

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".

Gort the Robot
  • 14,733
  • 4
  • 51
  • 60
  • So, I shouldn't group them? I should rather think of them individually as different things? –  Dec 15 '14 at 00:44
  • 2
    I have no clue, because I have no idea how you are grouping things. If you are making groups of ways people format data, then yes, they belong together. If you are making groups based on the first letter of their name, then no, they shouldn't be grouped together. – Gort the Robot Dec 15 '14 at 00:48
  • 1
    "YAML Ain't Markup Language" doesn't lend much credence to your implicit idea that YAML is a markup language... – raptortech97 Dec 15 '14 at 12:26
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.

Evan Plaice
  • 5,725
  • 2
  • 24
  • 34
  • 2
    HTML and Ant would be good examples of Declarative languages, however YAML and XML aren't specifying what computation should be performed. They just *are*, so I think it's worth mentioning. – Neil Dec 15 '14 at 09:01
  • @GlenH7 JSON **is** a language, specifically it's a context-free language that follows a context-free grammar. It's not a 'language' in the classical Turing complete sense but that's why the different levels of classification exist. – Evan Plaice Dec 15 '14 at 18:02
  • @Neil "aren't specifying what computation should be performed". That's the *point*. Declarative languages aren't required to illustrate **how** the program should perform a task. They only describe the **what**. In the case of HTML/ant the data describes steps that the program should take to construct a document or perform a list of tasks. Their structure is **not** imperative, though their data/structure can be used to denote the steps that an imperative program should take. – Evan Plaice Dec 15 '14 at 18:08
  • @GlenH7 It doesn't matter whether it's a formal language or a subset of another. It can be produced and consumed in a context free manner using a well defined context free grammer. I'm defining the behavior declarative languages based on the characteristics of how they're used and parsed. Your edit was unrelated to my original goal/intention. – Evan Plaice Dec 15 '14 at 18:19
  • I never claimed that it wasn't a language. You said, "A program that describes what computation should be performed and not how to compute it." Unless you want to start calling JSON a program, I am simply pointing out the err in that definition. Perhaps it was wikipedia's definition, that doesn't mean that I will start calling JSON a program. You should correct it here, and ideally on the wiki page as well. – Neil Dec 16 '14 at 08:23
  • 1
    @Neil OK, I agree then. Wikipedia's defining it as a 'program' is is wrong, unless you take a very liberal view of what a 'program' actually is. I guess that you could say that a HTML source file is a 'program' but HTML is strictly declarative so it requires a HTML client to be useful. In comparison to English language structure. Where a programming language would contain nouns (ie data), and verbs (ie statements, subroutines). A declarative language contains only nouns, it isn't capable of performing defining actions on its own. – Evan Plaice Dec 16 '14 at 20:23
  • @EvanPlaice: YAML and XML not only don't specify "what computation should be performed" they also don't specify what task should be done or result is desired. The only "what" they have is the data. – jmoreno Dec 17 '14 at 19:06
2

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.

jmoreno
  • 10,640
  • 1
  • 31
  • 48