Is HTML a programming language? I could express a bit of shock, even dismay, at the question, but instead, I'll try a more polished approach. In some sense, it may be a legitimate question, in which case it deserves a fair answer. In another sense, it may be an attempt at gatekeeping. I suppose that also must be addressed.
My first concern is, what value would it be to say it isn't a programming language? Does it bring us some clarity as to its purpose? Is there a doubt that HTML is used by programmers to create UIs? Is there doubt that HTML has source code? Do we doubt that HTML source code is subject to the same issue systems, requirements management, version control, peer review, and testing like any other source code? I'm not certain what clarity it would bring to say it isn't a programming language.
However, before I conjecture on what else we could be asking, let's take a more technical look.
HTML is a declarative programming language. Unlike an imperative programming language, which tells a computer how to do things, a declarative language tells the computer what the result should be. The engine that processes the code figures out a way to get the system in that state.
There are a lot of domain-specific declarative programming languages. Configuration files generally fall into this same category. The lists of options declare how you want a system configured. In DevOps, configuration is consistently referred to as code.
Occasionally we'll see Turing completeness brought up in the discussion. Turing machines have been a wonderful tool in analyzing computation, and algorithms in general. They are used when talking about computability, whether we can find the answer to a problem. Though they can simulate a lot of languages and machines, they're terrible models of real-world practical computing. They simulate, but can not model, many features we'd expect -- including something basic like random access lists.
If we're asking what a programming language is, I think we need to stay at the practical level. Let's leave Turing completeness to the theory. A proper discussion in that realm requires going into a lot more detail. I'm not dismissing it. I find it fascinating, but not relevant to our question.
What might be a practical definition? How about a programming language is a set of codes that unambiguously instructs a computer as to what it should do. HTML instructs the computer how to create a visual document, or app interface, for the user. Python, Java, or C++ give sequences of commands that tell the computer how to manipulate memory, modify files and talk on the network. Haskel, or O'Caml create structures of equations that calculate results.
I might need to be careful with that "unambiguous" bit, as many languages have dark corners to them: unintentional defects in the language, intentionally unspecified behaviour, and the outright nasty undefined behaviours. So, we'll have to live with for-the-most-part unambiguous.
Different languages instruct the computer differently. We recognize they aren't all appropriate for every situation. There is no all-domain all-purpose language anymore.
Back to the question then, what value does it bring to say HTML isn't a programming language? I fear the answer is related to gatekeeping. Some individuals feel a need to distinguish the quality of programmers based on some artificial goal posts. It helps keep the role of programmer artificially elite -- for some definition of elite.
It's not like the label "programmer" magically makes one qualified to do all types of programming. It's a large field. We have lots of tools and lots of approaches. Somebody who knows only HTML won't likely be hired to program a game engine or embedded sensor. Nor would a data analyst specializing in NumPy be a good fit for a mobile interface.
But even still, who only knows HTML? Perhaps we're talking about UI/UX designers that use it to create prototypes. These are people that will work with a programmer to help them get what they want. I don't think they're clamouring to be recognized as programmers themselves? I do consider them developers though; I have a chapter in my book about why I think this is important.
Otherwise, most of the web programmers I've met doing HTML seem also to be doing CSS and JavaScript. It's difficult to program an interface using only HTML; it's inevitably combined with other technology. It needn't be, but that's the most common situation. If somebody wishes to deny JavaScript as a programming language, well, let's just ignore that foolishness.
In summary, HTML is a declarative programming language. It can't do everything, but no language can. There's no practical value in saying it isn't a programming language. Though a programmer who knows only one language is limited in what they can do, this applies to all languages, including JavaScript, C#, Python, or whatever. We could argue that this theoretical person who knows only HTML is not a well-rounded programmer, but not that they aren't a programmer at all. Instead of trying to exclude them, why not work with them, and encourage them to learn all the other beautiful things that can be done?
Read my book What is Programming? and learn what it takes to be a great programmer. I look at the People, the reason software exists, the code at the heart of that software, and you, the person behind the keyboard.
Top comments (22)
"what value would it be to say it isn't a programming language"
What value would it be to say it is one?
Some people feel better when they say HTML isn't a programming language because they think they are now better than people who only know HTML.
Some people feel better when they say HTML is a programming language because they now think they're on a level with people who know other languages.
Both don't add anything meaningful to the discussion.
Quite correct.
I think the only meaningul distinction is between a general purpose programming language, and a domain-specific programming language.
It seems to me that HTML is the latter.
Qualifying it as a "true" or "false" programming language (or Scotsman, wink wink) doesn't really matter, however I do think qualifying it as a DSL does add meaning.
You could say the same about any categorisation. There is a reason why you are a human, a mammal, an animal, a life form. Those might seem unnecessary labels but they tell us what you do, what you are capable of. Same with languages.
Indeed.
There is a point at which all meaning is lost in detail, and that is in general, not where you want to be. Hence my approach to try and find a lowest common denominator that lessens my own cognitive load.
Sure, but seems like semantics to me.
Is it a markup language or a domain-specific language?
Isn't a markup language a domain-specific language?
In my opinion, semantics matter. Granted, only up to a point, but I personally draw my own line there. DSL is good enough for me, that's all I'm really saying, I'm not trying to solve a metaphysical issue.
No: HTML is not a programming language.
Also No: this doesn't mean it's any less valuable of a skill.
Also not programming languages: xml, yaml, json, markdown. They don't need to be called programming languages to be considered valuable skills.
Saying HTML is not a programming language while JavaScript is, makes no comparison between the 2 languages at all. It is indicative of each language's abilities and uses.
HTML - some text which makes computer do something e.g. display a form or a text etc. How that is not a programming language?
Here is good paper on PL classification if you have any further doubts
HTML does not make, or instruct, the computer to do anything.
The above HTML snippet could be viewed as a key/value pair. The key being
title
and value beingPage
. There is no instruction to store, display, or interpret this value.Another way to view it is that there is one piece of information "Page", which has markup code wrapped around it to define what type of data it is, "title". In being a markup language HTML essentially defines meta-data.
HTML has no instructions, it cannot actively do anything or instruct a computer to do anything.
Again, this does not make it any less or more in status than a programming language. A markup language just isn't a programming language; and that's OK.
I think the distinction between markup and program/logic code is important, it's a matter of accuracy and managing expectations.
You saying "instruct" as if
alert('Hey')
(or any other JS function) have some magic powers to actually instruct computer. No it doesn't. Browser reads it, converts to instruction set, sends it processor (or GPU or...) and eventually machine executes it.What happens with HTML? Browser reads it, converts it to instruction and send it to machine, which executes it.
That sounds like over-simplyfication to me.
You could also say that about writing into Word document. Word have to do the same to be able to display formatted document, but it doesn't make Word a programming language.
I'm not fully agree with the idea. HTML is a markup language, it contains no programming logic and is not Turing complete.
We must distinguish between languages, otherwise will be a general confusion and someone can consider any language as a general purpose programming languages.
Please point to the dictionary that states that Turing completeness is a requirement for a programming language. I will save you some time... they don't.
Where'd you get those rules though? I don't agree with them, personally. I'd rather use a definition more like, "A programming language is any human-readable language that allows a writer (i.e. programmer) to unambiguously instruct the computer to perform a desired set of actions". HTML certainly falls into that definition.
And anyway, while HTML on its own may not fit your above three rules, I'd argue that the HTML+CSS combination does.
@media
queries,:nth-child()
selectors, etc.@
-rules like@media
queries "change the flow of execution" in that they produce a different set of CSS rules, which changes the flow of the rendering pipeline.To be honest, these rules are pretty questionable even outside of this discussion, especially the
goto
rule. There's no nativegoto
in many classic languages, e.g. JavaScript, Haskell, Prolog, and many Schemes. If you didn't mean a literalgoto
, but rather anything that allows moving to another bit of code at will, then how does this differ from the function call rule?This is sort of beside the point of the article, but I think another interesting approach to take on this age-old topic is to consider HTML+CSS together as a programming language instead of just HTML by itself. CSS layers on top of HTML, and it introduces a lot of constructs that could be considered logical statements and execution-flow-controls, e.g.
@
rules and:nth-child()
selectors.I definitely agree with you here. Prior to reading this article, I have always seen HTML as strictly a markup language that defines the structure of a document. Indeed, it is "just a markup language", but combined with other technologies such as CSS, JavaScript, and a proper browser (with an HTML parser), it is capable of so much more than "just being a markup language". In a way, it is the ultimate programming language of UI.
Thank you for this article. It definitely gave me a whole new perspective on this "debate".
Great post. I would call HTML a programming language. It is a simpler one than others, but is a programming language nonetheless. I think the best thing you bring up is the gatekeeping that is so very prevalent in the Developer community. There is a large number of folks who seem so intent on keeping what they do as magical and as mystical as possible in some weird process of keeping their value at the thing they do. But, instead what we should be doing is bringing in everyone who wants to be here. There is so much variety to what code and programming can do that there is room for everyone who wants to learn at all levels. Our value comes from what we can teach others and helping them find ways to express their ideas, not from keeping secrets about our magical processes.
How do you like my joke?
I would consider computation, i.e. transformation of data, as the essence of of a programming language. And the only form of computation, if you will, that HTML is capabale of, is producing constant functions, which, given arbitrary input, will yield a static data structure - albeit one that can certainly be quite complex and very useful.
That being said, that a formal language doesn't constitute a programming language, diminishes its value and importance in absolutely no way. A software system consists of many different artifacts, of which HTML often is an one. And by the way, I also count requirement specifications and user documentation to artifacts that are vital part of a software system. And those are both, at least in most cases, artifacts that, in contrast to HTML, neither follow a formal grammar nor are executable. Computational capabilities the only property that makes something a useful or important.
To conclude, although I disagreeing with the proposed definition for programming language, which is premise of your argument, I indeed very much appreciate the articles sentiment of speaking out against gatekeeping in software development, which in the process of creating a working system isn't useful at all.
I agree, of course it is a programming language. There is not really any counter argument, only convention. The rest is just an inability to understand either English or computers. If someone is not capable of realizing that HTML is used to give instructions then they really need to go off and learn something before engaging in the "discussion" (it is not really a discussion).
To program simply means to provide instructions. It is there staring at you if one takes the time to look at a dictionary (which I am guessing people are failing to do). A program is a set of instructions. HTML is a language used to give instructions... discussion over - it is by definition: a programming language.
Yes, of course mark-up can be used to provide instructions! Is XML a programming language? NO... but the similarity is simply in the way it looks. You are labeling a bunch of values in XML. You are giving instructions with HTML. If I want a load of text to be a heading I "instruct" the browser to do that with h1 or h2 etc...