CodeNewbie Community

loading...

What makes HTML a “markup language” and not a “programming language?“

carolineschettler
・1 min read

Discussion (4)

Collapse
alvaro_montoro profile image
Álvaro Montoro

People associate Turing completeness with being a programming language and use that as unique criteria to define what a programming language is. Personally, I see this as a misconception, a programming language can be Turing complete or not. Both concepts are not mutually exclusive: markup languages are a subset of the group programming languages.

Collapse
vonheikemen profile image
Heiker

Depends on your definition of programming language.

I've notice that people who go against HTML being programming language tend to focus on these points:

  • The words "markup language" are in the name.
  • You cannot express logic with it.
  • It was designed to "just describe" things.
  • It doesn't communicate with an operating system directly.

I've also notice that a lot of those people are just trying to come up with an excuse to say HTML is not "worthy" of them. After a while they start saying a bunch of nonsense, so it's hard for me to take them seriously.

Collapse
alvaro_montoro profile image
Álvaro Montoro

Animated gid with the text "this. all of this" appearing while a man points up (to the previous comment)

Collapse
reinhart1010 profile image
Reinhart Previano Koentjoro • Edited

I personally consider HTML as a separate data structure file format (similar to JSON, YAML, and TOML) instead of just a “markup language”, which can then be parsed and used by programming languages to store and load data.

Standard-wise, the HTML itself is originally based/inspired from XML and other SGML-based markup languages. Before JSON were introduced, websites share their data between servers and clients commonly by sending XML data via SOAP. A typical XML document, such as

<response>
  <statusCode>200</statusCode>
  <body>
    <city>Istanbul</city>
    <country>Turkey</country>
  </body>
</response>
Enter fullscreen mode Exit fullscreen mode

can be represented into JSON format such as

{
  "response": 200,
  "body": {
    "city": "Istanbul",
    "country": "Turkey"
  }
}
Enter fullscreen mode Exit fullscreen mode

Certain data structures such as arrays can be emulated in XML by repeatedly using the same tags. In HTML you might create an unordered list (aka. bullet points) this way:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>
Enter fullscreen mode Exit fullscreen mode

Which is similar to this in JSON

{
  "ul": ["Item 1", "Item 2", "Item 3"]
}
Enter fullscreen mode Exit fullscreen mode

Web browsers which are able to render the HTML document will first try to parse the file into a set of data structures understood by web browsers’ programming languages (typically C++ and Rust, in the form of DOM / Document Object Model tree), then try to render the HTML by connecting it with a graphics API or library. Many programming language compilers and intepreters, however, perform more tasks than simply analyze and parse the source code written in that programming language, such as C/C++ which then tries to compile the code into an Assembly format compatible for specific types of processors (x64, ARM, RISC-V, etc.)

Hence, the definition of HTML as a programming language itself depends by people’s opinion, but I still can assure that HTML can be a subset of another programming language. This is true due to the fact that similar markup languages such as XML are often used in defining layouts and user interfaces for other types of software (such as Android app development and even Microsoft Office itself*), while HTML and XML itself is principally similar to other forms of data structure file formats such as JSON, YAML, and TOML.