Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
6  
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 –  Ian Carroll Apr 26 '13 at 16:57
1  
@zxcdw, CSS3 is a programming language indeed, since it is Turing-complete. github.com/elitheeli/stupid-machines/blob/master/rule110/… –  SK-logic Apr 26 '13 at 17:01
    
@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. –  delnan 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
show 3 more comments

marked as duplicate by MichaelT, Jimmy Hoffa, Yannis Rizos Apr 26 '13 at 18:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6 Answers

up vote 10 down vote accepted

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.

share|improve this answer
    
+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
add comment

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.

share|improve this answer
    
So I take it that rules out HTML –  Ian Carroll 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. –  m3th0dman Apr 26 '13 at 16:30
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
show 6 more comments

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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). –  delnan 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. –  m3th0dman Apr 27 '13 at 6:09
add comment

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

share|improve this answer
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
add comment

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

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.