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?
Programming Languages – Differences Between Programming, Markup, and Scripting Languages
markupprogramming-languagesscriptingterminology
Related Solutions
Your understanding is correct, if you're from the past. You're pretty much describe as it looked like in 1990s.
Yes, many languages can be executed directly by a web server plugin. Right on for PHP, mod_php for Apache is still the most popular way to host it. However, high-traffic sites use more modern approach, using web server only as a proxy for FastCGI (in case of PHP it's PHP-FPM)
the output is embed into HTML pages is then sent back to the client.
I think you're referring to early 90's so called spaghetti code, however modern approach is to use one of many MVC frameworks. In case of PHP that would mean for example Zend Framework (there are numerous alternatives).
As for ASP, you're probably referring to so called "classic ASP", which is obsolete. Currently it's ASP.NET, which can use any of .NET languages (C# being the most popular), and of course the .NET framework.
C and C++ are not typically used for web application. If so, such services are implemented either as stand alone servers, as module for web server or as FastCGI.
Perl can be executed directly from web serve module using mod_perl. There is also PSGI, which is basically clone of Python's WSGI.
Python is very popular language for web apps. It can be directly executed from Apache web server via mod_python, however that is obsolete and not recommended. Currently the way to go with Python is either via WSGI server module. WSGI server implemented in Python (eg. CherryPy, WebPy) or using stand alone Python web stack (Tornado and Twisted's Web module are fine examples). And of course again, you'd most probably will be using WSGI compatible MVC framework, Django is the most popular one (again, multiple alternatives available).
Ruby, again very popular language for web apps. Best known for web framework Ruby on Rails, which again is MVC. You can execute Ruby directly from server module via mod_ruby or via FastCGI.
Servlets/JSP are executed in stand-alone J2EE application servers, such as JBoss or Tomcat. It's more commonly used to add web interface to business system rather than to create stand alone web apps.
Classical CGI (ie. spawning process on each request) has become obsolete many years ago. It has been replaced by FastCGI (where process is long-running, rather than spawned on each request), server modules, interfaces such as WSGI and clones and stand-alone solutions.
Also the paradigm of the request processing has evolved, with CGI it was process per request. Then was process pool (or thread pool), each process (thread) handling one request at a time. However now, most modern approach is for web servers and stand-alone frameworks to use event-driven programming.
A programming language is a notation designed to pass instructions to a machine. By that definition both C++ and HTML are programming languages, as was the notation Joseph Marie Jacquard used in 1801 to program his looms.
However with the proliferation of languages that are used to structure and/or describe data, the definition of a programming language shifted to include only languages that are capable of expressing algorithms. This is the more common definition today and it excludes languages like HTML or XML.
At the heart of the current definition is the concept of Turing completeness. Most programming languages are Turing complete, and Turing completeness is often quoted as the one critical trait that separates a programming language from any other computer language. This is good enough as a general rule of thumb, but not entirely accurate:
- Some non Turing complete languages are considered programming languages, for example Charity.
- Some languages that are not generally considered programming languages are Turing complete, for example XSLT.
- Turing completeness alone doesn't say much about a language's usefulness.
Depending on context, you can pick any definition you want.
Edit:
Let it further be known, an implementation of a language does not confer characteristics onto the language itself, for example: A language's spec may define a turing complete language, someone could implement it haphazardly leaving off turing completeness. This implementation being non-turing complete does not however mean the language itself is not turing complete (rather it likely means that implementation is non-conformant). The details of a language and the details of a particular implementation of a language are to be recognized as separate things, this is why it's inaccurate to call a language interpreted or compiled etc.
Best Answer
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.