A person I met recently had an argument. It was that a programming language had to be compiled to be considered a programming language. This would make HTML/CSS (unless you’re using SCSS or LESS) not a programming language. So, does it have to be compiled?
8
HTML and CSS aren’t commonly considered programming languages, but not because of how they are implemented. They’re markup languages, you don’t program in them, you only specify content and its presentation. They’re computer languages, but not for programming things, so they aren’t programming languages. Although recent CSS standards allow some computations (and I think they’re even turing-complete) it’s not even close to anything the language is intended or suitable for.
But that doesn’t seem to be the core question. No, compilation is not required for something to be a programming language — that doesn’t even make sense. It betrays a pretty fundamental misunderstanding (any language can be implemented with both interpretation and compilation), and the conclusions to be drawn from that radically contradict the consensus. Whoever thinks that most likely also uses objectionable (though sadly more common, and thus harder to dismiss) definitions of “compilation” and may draw artificial distinctions such as “scripting language/(real) programming language” too. It’s probably best to ignore their opinion on this topic.
1
The simple answer is no. Neither HTML nor CSS is a programming language.
However, there are other indicators
- variables or objects:
int x;
- assignments:
x = 3;
- expressions:
x * 5
- functions:
int doubleMyInt(int a) { return a*2; }
- statements (e.g. as assignments, expressions and variable declarations)
- conditionals:
if(x > 10) { x = 10; }
- loops (for, while, do while, until,…)
I suggest reading this incredibly interesting article which comprehensively covers this exact topic.
10
No.
There have been many, many programming languages that were implemented with an interpreter. Some of them saw lots of commercial use. Ever heard of dBase II? It was an interpreter-based language and system.
The first BASIC implementation, at Dartmouth, was in fact compiler-based, but large numbers of subsequent implementations were only interpreter-based. Bill Gates and Paul Allen got their start by writing a BASIC interpreter (and a bootstrap loader to load it) for the Altair 8800.
A language is a programming language if by some means (compilation, interpretation or both) the instructions of the language are directly transformed into instructions that can be executed by a CPU, that is to instruct the CPU what to do. From another point of view, a programming language is a language in which you can describe an algorithm.
Now in HTML or CSS you cannot tell to the CPU what to do neither can you describe algorithms.
4
No, a programming language does not have to be compiled.
However, a proper programming language does need to be able to implement the same class of algorithms that other programming languages can; this property is called Turing completeness.
HTML and CSS are not real programming languages because they can only specify a limited class of computations; they can’t describe an arbitrary loop. Because it is important that web pages can be displayed quickly and reliably, HTML and CSS have been designed so that they are guaranteed to terminate — if they could describe an arbitrary loop, a broken or malicious web site could lock up the display engine indefinitely, as it tries to evaluate the basic HTML and CSS.
On the other hand, Javascript is a real programming language. Interpreted or not, it has has the expressive power that HTML and CSS lack: any kind of computation available in C/C++ can be described in Javascript. It may not be pretty, and it may not be convenient, and it may not be efficient, but the expressive power is what makes a real programming language.
Addition: some of the comments mention that CSS3 is Turing-complete. This is arguably, technically true in the sense that you can encode a cellular automaton in it — but, if I understand correctly, any evaluation of the CSS can only take one step of the cellular automaton.
To put it another way: the “loop” that enables CSS3 to be Turing-complete is a loop of the user reevaluating the CSS. As one answer to this question puts it: “calling non-Turing-complete code in a loop can make it Turing-complete”.
1
Ask the person what does (s)he mean by programming language, or simply programming. There are many scripting programming languages that aren’t compiled (such as shell scripts), or only optionally compiled (such as JavaScript – it’s only compiled for efficiency). For more examples see the list of interpreted languages. Does the person insist on that none of them is a programming language?
Perhaps even more exotic example is XSLT – eXtensible Stylesheet Language Transformations for XML. An XSLT stylesheet is an XML document (such as this example), yet it is Turing complete, which means that you can express any algorithm in it. Since many of XSLT processors optimize the process by compiling a stylesheet into code, you have a language that is both compiled and Turing complete. So you could make an argument like:
- “Do you consider XSLT a programming language?”
- (Most likely the answer will be “no”.)
- “Why not? It is Turing complete and compiled.”
(I’d be curious to see where it goes.)