I recently ran a poll on Mastodon about knowledge of HTML among programmers.
Poll on Mastodon (mastodon.social)
The results are interesting, as has been the discussion. Today I wanted to discuss a small aspect of this: HTML's unique role in the software ecosystem.
HTML is the World Wide Web's HyperText Markup Language. It was developed as the primary document format with the intention for the web to serve documents linked using hyperlinks. The web browser used to read this page reads HTML and renders it as a document.
Traditionally, programmers tend to differentiate programming languages along various axes. One such axis is the distinction between languages which can compile into programs a computer can directly execute, and those which are interpreted by another program that actually performs the programmed logic. Another axis is the distinction between programming languages which encode logic and algorithms from those which merely describe some kind of data or mark up some text. Markup and data description languages tends largely to fall into the camp of interpreted languages, because their lack of logical constructs means it is incoherent to build a machine-executable binary from them. In other words, markup languages are a subset of interpreted languages.
On the other hand, source code for compiled languages such as C are fed to a compiler which directly produces a resultant machine executable… right?
Well, no.
A C compiler reads C code, and emits a corresponding platform-specific Assembly Language code. Then, a separate program called an assembler assembles the Assembly code into an object file. Lastly, a linker links the objects together with the program's dependent libraries and platform runtime into a final binary executable file. Most compilers and software build systems compress this process down into a simple C→executable step, but the underlying process remains the same.
C itself is three levels removed from the actual production of a working executable, and is mostly relevant only in the process of emitting assembly language code. Does it truly make sense to view C as a "compiled" language? All the C compiler does is read C code, and perform certain operations based on what the code is—just like an interpreter.
On the flip side, is Lua a compiled language? The Lua interpreter includes the ability to compile a Lua module to bytecode. Lua bytecode needs to be executed by the Lua interpreter, but the same could be said of Java bytecode—and Java is generally understood to be a compiled language. As if that wasn't enough, Lua code doesn't need to be assembled and linked; The process of compiling to bytecode is more direct than in compiling C to machine code. The only functional difference between an interpreter and a bytecode VM is that bytecode is usually not hand-written.
Consider next a program that reads data and produces some kind of report. Like a compiler or interpreter, some input is read, some operations are performed based on the input, and some results are generated. Like with bytecode virtual machines, having input that was generated by another program doesn't change an interpreter's fundamental nature—and that is fundamentaly what a report generator is.
Finally, we can circle back to web browsers. A web browser is an interpreter for a myriad of programming languages, such as CSS, Javascript, and—of course—HTML. HTML is a language for writing documents to be rendered by a web browser. In another sense, an HTML document is a program that a web browser interprets to determine how to display the information that has been encoded. There's nothing special about HTML that disqualiifes it from being a programming language.
Besides, HTML is already known to be Turing-complete. Any program that can be written, can be written entirely in HTML. The only reason to claim HTML is "not a real programming language" is elitism, gatekeeping, or otherwise to dismiss another person's learned skill in being able to write it.
With that said, why is my initial poll worded in such a way that it implies one can know HTML without being a programmer?
More to come.