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.

Up until now I don't know the KEY differences between these three. When someone asks me about this, I only tell them that C# is a programming language, HTML and XML are Markup Languages, and JavaScript and VBScript are scripting languages. But what are the key differences that distinguish them from one another?

share|improve this question
add comment

3 Answers 3

up vote 14 down vote accepted

Let me attempt to find a dividing line between these three types of language. Of course, there will be numerous exceptions and counterexamples, since this is just my opinion.

  • A markup language is used to control the presentation of data, like "represent these user names as a bullet list or as a table".

  • A scripting language is used to mediate between programs in order to generate data. This is specially true of shell scripting languages like bash, but if you reflect about it, also Python or Perl came from the need to accomplish tasks in UNIX without writing a program in C. The program that you control most of the time in those languages is the interpreter of the language itself, which accomplishes general tasks for you. Other typical programs you interact with are database servers, or web servers.

    Going back to the user list metaphor, in a scripting language you ask the database "give me all user names", then ask the web server "send this user list to this requester".

  • A programming language is used to transform data. It does so by creating CPU instructions that rewrite the input data into the output; hopefully, the desired output. Examples of transforming data is to compute a sum out of a number of addends, or solving a system of differential equations from a set of conditions, or writing and reading from a tree-like structure in a consistent manner given a sequence of possibly simultaneous queries.

    Going back to the user list metaphor, in a programming language you write how to traverse a table of records, extract from each record the "name" field, and return all of them to the requester.

Note that scripting languages are a subset of programming languages i.e. a language may be both "scripting" and "programming": Python is regularly used to "mediate between programs", and also to "transform data". There are other languages like Java which are seldom used to "mediate between programs", not because this is impossible but because they are not designed to make this easy. The key feature of a scripting language is that it can orchestrate other programs, just like a script gives the cue to an actor to start his part.

share|improve this answer
1  
Scripting languages are formally a subclass of programming languages. (I've also seen languages like C and Java being fully interpreted, with a REPL; the barrier is leaky both ways…) –  Donal Fellows May 26 at 11:24
    
@DonalFellows: you are right. I answered with that in mind, but I have not explicitly used the expression "one is a subset of the other". Also, I have not implied that one category is interpreted and the other is not, because I knew that is a weak distinction. –  logc May 26 at 11:32
    
@DonalFellows: I have edited my answer to explicitly mention that one is a subset of the other. –  logc May 26 at 12:23
1  
I support this answer for being the only one(so far) that claim that markup languages are languages that describe the structure of data. –  Idan Arye May 26 at 12:53
3  
@JörgWMittag: I knew there would be exceptions, that is why I started with "there will be numerous exceptions" :) Otherwise, where in my answer do I imply that a scripting language is not compiled? I tried to concentrate on the purpose of languages precisely in order to avoid that pitfall ... –  logc May 26 at 13:47
show 2 more comments

A markup language is a language which is used to represent structured data. For example, HTML enables to specify that some part of the document is a title or some other part is a list, by comparison to a flat text document.

Markup languages are not considered as programming languages¹.

The difference with programming languages is not always obvious. For example, XSLT is a Turing-complete language², but is based on XML which is a markup language.

Wikipedia itself makes important efforts to avoid qualifying XSLT as either a programming language or a markup language. It only says it's a declarative language, and that it uses “optimization techniques found in functional programming languages and database query languages”.

A scripting language is a programming language which is interpreted, rather than compiled, which means that scripting languages represent a subset of all programming languages.

It is not always obvious whether a programming language is a scripting language, like it's not always obvious whether a language is compiled or interpreted. For example, PHP may be compiled to intermediate bytecode³ and then ranslated into machine code by JIT compiler, while being still considered as scripting language⁴.

See also: Splitting Meta-Hairs by Steven Lott.


¹ “XML is not a programming language”. See XML in 10 points.

² “XSLT is a Turing-complete language” See XSLT on Wikipedia

³ “HHVM compiles Hack and PHP into an intermediate bytecode. This bytecode is then translated into x64 machine code dynamically at runtime by a just-in-time (JIT) compiler.” See HHVM.

Scripting languages in List of programming languages by type on Wikipedia.

share|improve this answer
8  
Languages are never compiled or interpreted. Languages just are. Compilation and interpretation are traits of the compiler or interpreter (duh!) used to implement the language. The terms "compiled language" or "interpreted language" don't even make sense, they belong to different levels of abstraction. If Englisch were a typed language, "compiled language" would be a TypeError! Every language can be implemented by an interpreter, every language can be implemented by a compiler. –  Jörg W Mittag May 26 at 10:00
    
@JörgWMittag "Every language can be implemented by an interpreter, every language can be implemented by a compiler" - 100% true? –  spartacus May 26 at 13:36
    
@spartacus I'm calling that a hesitant "no". I think any language that can be compiled could also be interpreted (just execute the instruction instead of saving it), but I've heard that homoiconicity severely restricts the possibility of compilation –  Izkata May 26 at 16:20
    
@Izkata I wouldn't say homoiconicity itself changes the possibility of compilation, but rather the metaprogramming it allows means much compilation needs to be deferred to runtime, if at all. –  Mark Hurd May 28 at 5:27
add comment

A markup language is used to describe data rather than logic. A typical use of them is to describe document formating, HTML is designed for this for example. But they are sometimes used as general data formats as well, XML is a markup language that is often used to just describe data.

The difference between programming and scripting languages is very fuzzy, both tend to be turing complete in that you can solve any computable problems with them. There are some general 'hints' that you can look for to see if a language is a programming language or not.

  • Scripting Languages are often interpreted rather than compiled, or at least provide the option of being interpreted.
  • Scripting Languages are often built to be fast to work with rather than fast to run.
  • Scripting Languages tend to come with very extensive standard libraries. Many programming languages do as well, but it is more optional for them.

But in the end, if a language is scripting language or programming language is more a matter of convention rather than any strict criteria. Even the hints above are just trends, you will find programming languages that fulfill all the criteria for a scripting language yet are still considered programming languages.

share|improve this answer
3  
Languages are never compiled or interpreted. Languages just are. Compilation and interpretation are traits of the compiler or interpreter (duh!) used to implement the language. The terms "compiled language" or "interpreted language" don't even make sense, they belong to different levels of abstraction. If Englisch were a typed language, "compiled language" would be a TypeError! Every language can be implemented by an interpreter, every language can be implemented by a compiler. It is even possible to automatically generate a compiler from an interpreter and vice versa. –  Jörg W Mittag May 26 at 10:01
    
@JörgWMittag it's true that no language is inherently compiled or interpreted. But there are often conventions on how it is typically executed, which is mainly what I'm referring to here. –  Pierre Andersson May 26 at 13:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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