4

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?

Ixrec
  • 27,621
  • 15
  • 80
  • 87
  • 7
    No, because interpreted programming langauges exist too. HTML and CSS are not *programming languages*. You don't *program* anything with them. – zxcdw Apr 26 '13 at 16:27
  • Wow, this question became very popular. I think the question has been answered, and it should be closed because of dup's – StackExchange User Apr 26 '13 at 16:57
  • 1
    @zxcdw, CSS3 is a programming language indeed, since it is Turing-complete. https://github.com/elitheeli/stupid-machines/blob/master/rule110/rule110-full.html – SK-logic Apr 26 '13 at 17:01
  • 1
    @SK-logic CSS 3 is turing complete, but that is a crude metric for whether it's a programming language (as you point out in another comment, at the very least it's not a necessary condition). Go ask around. Even after explaining its turing completeness, I'd wager most people would not consider them, because CSS is still neither intended for programming nor practically usable for it. –  Apr 26 '13 at 17:11
  • @delnan, yes, and that's actually *the* answer. The bottomline is: there is no precise definition of programming language, so any such argument is pretty pointless. – SK-logic Apr 26 '13 at 17:37
  • @SK-logic You have to admit, you appear to be flip-flopping here. Why not point that out to begin with? ;-) –  Apr 26 '13 at 17:41
  • @delnan, that's deliberate, I'm proving the point. Turing completeness does make something a programming language (by many of the definitions floating around). Not being Turing-complete does not necessarily mean it's not a "programming language" (again, by some of the definitions). No single criteria can be chosen, therefore the question itself is pointless. – SK-logic Apr 26 '13 at 17:43
  • @SK-logic Then it's a pretty bad presentation of that proof IMHO. See various other answers for how to make such points (not the exact same point, yeah) *explicitly* rather than in a manner reminiscent of satire, and hence vulnerable to Poe's law. But whatever, this is getting off topic. –  Apr 26 '13 at 17:46

6 Answers6

12

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 for indicating whoever holds this belief should be seen with general skepticism. though I still think it's a good side note that a language is not defined by it's implementations and as such the implementation doesn't confer characteristics onto the language. Other than that; As always you know wth you're talking about. – Jimmy Hoffa Apr 26 '13 at 17:44
8

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.

Kilian Foth
  • 107,706
  • 45
  • 295
  • 310
Michael
  • 213
  • 1
  • 5
  • So I take it that rules out HTML – StackExchange User Apr 26 '13 at 16:16
  • 1
    @Ian Carroll, HTML rules out HTML the ML stand for Markup Language, it's for formatting content, not working with data or sending info over networks. – Ray Britton Apr 26 '13 at 16:18
  • 2
    There are turing complete languages which lack many of the features you speak of, these are really not good ways to identify a programming language. – Jimmy Hoffa Apr 26 '13 at 16:28
  • 3
    There are programming that don't have variables, assignments, conditionals or experesssions; Prolog is an example. – Random42 Apr 26 '13 at 16:30
  • @JimmyHoffa Turing completeness is not the criteria by which most people decide if a computer language is a programming language. CSS 3 is turing complete. The game of life is turing complete. SQL (or at least the 90% used by most programmers) is not turing complete, but considered something of a programming language by many. But yeah, not all of these "indicators" (note that it's not "requirements") are present in all programming languages. –  Apr 26 '13 at 16:31
  • 1
    Unlambda is a programming language, but you'll find none of your "indicators" there. Same for Brainfuck. – SK-logic Apr 26 '13 at 17:03
  • @SK-logic Brainfuck (Is that a real programming language)? XD – StackExchange User Apr 26 '13 at 17:09
  • @IanCarroll [Brainfuck](http://en.wikipedia.org/wiki/Brainfuck) is indeed a real language, though a so-called esoteric one. –  Apr 26 '13 at 17:17
  • @m3th0dman Of course it does, but at a rather indirect way. Consider conditions (`?- 3 < 4.`) and statements (`cat(tom).`). It also supports loops in terms of recursions (-> functions). See wikipedia for more { http://en.wikipedia.org/wiki/Prolog } – Michael Apr 26 '13 at 18:05
  • @Michael There are at least programming languages without assignments and variables - pure functional programming languages. – Random42 Apr 27 '13 at 06:00
  • @m3th0dman This is arguing about nitpicks, really. The list above contains *indicators*, not *must haves*. Even functional programming languages support most of the features listed there. – Michael Apr 27 '13 at 07:39
  • @m3th0dman an immutable variable is still a variable - and an assignment can be made. imo most of the power comes from having a name for something, not from being able to mutate it. – Thanos Tintinidis Mar 14 '16 at 11:11
1

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.

John R. Strohm
  • 18,043
  • 5
  • 46
  • 56
1

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.

Random42
  • 10,370
  • 10
  • 48
  • 65
  • I'm not understanding your first sentence, particularly if it rules out HTML, or includes languages like Python. Note also that the ability to describe an algorithm doesn't quite mean Turing-complete, in that algorithms terminate and it's impossible in general to tell whether a given Turing machine does. – David Thornley Apr 26 '13 at 17:10
  • @DavidThornley How does turing completeness even enter the picture? There's no mention of it in this answer (which isn't bad; many people ascribe far too much to it). –  Apr 26 '13 at 17:15
  • @delnan: Many people use Turing completeness as a guideline, so I thought I'd point out that this is not it. – David Thornley Apr 26 '13 at 17:33
  • @DavidThornley The syntactically correct statements of a programming language are directly and predictably transformed into machine code, which is to be executed by the CPU; the statements written in HTML or in CSS aren't transformed into machine code and are not executed by the CPU, thus HTML and CSS are not programming languages. From a pragmatic point of view we don't care if a language is Turing complete, we care if it can describe algorithms and any Turing complete language can describe any algorithms. – Random42 Apr 27 '13 at 06:09
0

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".

comingstorm
  • 2,727
  • 1
  • 13
  • 14
  • 2
    CSS3 does not guarantee termination. And some of the programming languages that do guarantee termination (and therefore are not Turing-complete) are still considered as programming languages (e.g., Coq). – SK-logic Apr 26 '13 at 17:06
0

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.)

Petr
  • 5,507
  • 3
  • 29
  • 46