DEV Community

loading...

Is HTML A Programming Language? — A Definitive Answer

uhyo_ profile image 🈚ïļã†ãēょðŸĪŠ ãƒŧ3 min read

Hello. I created the HTML programming language (THPL), a programming language whose source code is an HTML document. Therefore, HTML is a programming language!

Visit THPL Tutorial to learn more about THPL.

Here are a couple of examples.

Hello World in HTML:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>My First HTML Program</title>
    <script src="https://unpkg.com/the-html-programming-language@0.1.0/browser.min.js"></script>
  </head>
  <body>
    <p><output>Hello, world!</output></p>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Even FizzBuzz in HTML is possible:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>FizzBuzz</title>
    <script src="https://unpkg.com/the-html-programming-language@0.1.0/browser.min.js"></script>
  </head>
  <body>
    <section title="fizzbuzz">
      <dl>
        <dt>rem3</dt>
        <dd>
          <abbr>
            <math><rem /></math><br />
            <slot></slot><br />3
          </abbr>
        </dd>
        <dt>rem5</dt>
        <dd>
          <abbr>
            <math><rem /></math><br />
            <slot></slot><br />5
          </abbr>
        </dd>
        <dt>text</dt>
        <dd>
          <abbr>
            <math><eq /></math><br /><var>rem3</var><br /><meter>0</meter></abbr
          ><abbr>
            <math><eq /></math><br /><var>rem5</var><br /><meter>0</meter></abbr
          ><ruby>
            <span>00</span>
            <rt><slot></slot></rt>
            <span>10</span>
            <rt>Fizz</rt>
            <span>01</span>
            <rt>Buzz</rt>
            <span>11</span>
            <rt>FizzBuzz</rt>
          </ruby>
        </dd>
      </dl>
      <p>
        <output><var>text</var><wbr /></output>
      </p>
      <footer>
        <slot></slot>
        <ruby>
          <meter>100</meter>
          <rt><span></span></rt>
          <rt
            ><abbr title="fizzbuzz">
              <abbr
                ><math><plus /></math><br /><slot></slot><br />1</abbr
              >
            </abbr></rt
          >
        </ruby>
      </footer>
    </section>
    <p>
      <abbr title="fizzbuzz"><meter>1</meter></abbr>
    </p>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Now it's obvious that you can write programs in HTML!

Q&As

I have gathered feedback from a Japanese community. Here are feedbacks and answers to them in a form of Q&As.

Q: But a script tag exists in your source code, so the HTML document itself is not a program.

A: the script tag exists only for automatically executing the HTML program when opened with a browser, so this is not essential for HTML to be a programming language.

Q: you need a JavaScript interpreter to run an HTML program. This means that HTML is not a standalone programming language.

A: Yeah. Then Ruby is not a programming language because it is run by a C interpreter, right?

Q: But HTML identifies itself as a markup language, not programming language.

A: You should already know that name is no more than historical stuff. Please complain that JavaScript is calling itself Java first.

Q: What you created is only that THPL interpreter thing, so HTML is not affected at all.

A: The THPL interpreter is just an auxiliary tool that helps understanding THPL. Defining syntax and semantics is essential for something to be a programming language. Syntax already exists for HTML, and I defined semantics directly onto HTML, so HTML is now a programming language.

Q: HTML is a language for defining document data in the form of tree structure, not a program. HTML is more like JSON, YAML or S-expression, which are still not programming languages.

A: This point is worth discussing, but please remember that programs are finally interpreted as abstract syntax trees. In this sense, code for normal programming languages can also be seen as one that defines data in the form of tree structure. With this in mind, difference between HTML and other programming languages are quite vague.

Q: But program ASTs are different from other data formats in that they don't have other uses. HTML is originally for document markups, and JSON and YAML are for general purpose data exchange.

A: Okay, please wait for my next project which uses JavaScript programs as general-purpose data format. Then you would say JavaScript is not a programming language.


Now what do you think? Is HTML a programming language? Discuss!

Discussion (1)

Collapse
codinghusi profile image
Gerrit Weiermann

Wow you put much effort in it to claim that 😅

Forem Open with the Forem app