Tags

, , , , , , , , , ,

A webpage is a text document written in HTML. This document may also contain CSS and/or JavaScript, but it’s basically an HTML text document. You could write one — including the CSS and JavaScript — using just a pencil and paper.

Despite not needing a computer to write, all three are computer languages — they are languages used by, understood by, computers (and trained humans). However only one of those (JavaScript) is a programming language.

This is a brief explanation of which is which and why.

A computer language is any language a computer understands. Its purpose is to provide a way to tell the computer to do something. If you want a bold font, you have to tell the computer to use a bold font. If you want an image of a certain size on the left, you have to tell the computer to insert it.

Given that computers are still incredibly stupid, computer languages are carefully designed to be clearly understood by simple-minded idiots. A difficulty for humans is that they’re often too smart to easily grasp computer languages.

“Pick up that glass,” is too complicated for a computer to have any clue what you mean. For that matter, “that glass,” is too complicated. Did you mean some broken glass or a water-glass? For that matter, what do “glass” or “water” or “broken” (or “pick” or “up”) mean?

For a computer it’s more like: Look here. See this? Reach out. Grasp it. Look there. See that? Move grasped thing to that. Let go. Retract hand. Relax. All done!

There can be many layers or levels between a computer language and what the hardware actual sees as instructions. Each layer takes a richer language and converts it to a simpler language for the next layer. Given enough layers, you actually can say, “Pick up that glass.”

§

There is a very important — but sometimes fuzzy — distinction regarding how a computer language tells a computer what to do.

Some computer languages are just data — some form of content. The content can be very rich; it can include text formatting and images, even sound.

An HTML document has meta-data that tells the computer how to format the text, where to put images and tables, how to build lists. The regular data provides the textual content you read.

An HTML document can (but doesn’t have to) contain instructions in CSS — a separate computer language that provides another (better) way to tell the computer how to format your text.

Both of these are just content, just data. They are not “active” or “intelligent” or even “dynamic.” Which brings us to the other type of computer language.

Some computer languages —programming languages — are code. Whatever they tell the computer to do, the result may have nothing in common with the code. (This is a key consequence of the distinction, not a definition.) It’s possible some part of the result may be visible in the code, but there is no required connection at all.

For example, consider the following “code”:

print "Hello, World!"

mandelbrotClearly the expected output is found in the code itself. But consider code that creates a fractal image. There is no part of the image in the code. At a very high level, the “code” for the Mandelbrot fractal looks like this:

Z = Z2 + C

And from that comes the Mandelbrot. Looks totally different on TV.

§

There are three basic characteristics a computer language must have to be considered a programming language:

  1. Selection — if and case statements
  2. Iteration — while, until and for statements
  3. Storage – variables!

Selection: A programming language must be able to make choices depending on current conditions. The simplest expression of this is the if statement. A more complicated version is a case or switch statement.

Iteration: A programming language must be able to loop. There are different ways to accomplish this. The simplest is the while loop (and its inverse, the until loop). Some languages use recursion to accomplish iteration. Really crude languages use the goto (combined with an if).

Storage: A way to save the state of information as it is processed. Variables (which come in a vast variety of types and kinds) are the standard way to save state. Variables represent the data within the code, and the science of variables (Type theory) is rich and complex.

§

HTML and CSS do not have any of the three required elements of a programming language. They are computer languages, but not programming languages.


HTMLHyper-Text Markup Language. A computer language for writing web pages. (Any text with links to other text is called hyper-text. Markup is extra information about text formatting, images, tables, lists, and anything not actually text.)

CSSCascaded Style Sheets. A computer language for inserting text formatting meta-data into an HTML document.

JavaScript — A programming language. Commonly used to add dynamic behavior to a webpage.

Java — Also a programming language.  But one that is completely different from JavaScript!

Python, Perl, Haskell, Ruby, B, BPCL, C, C++, C#, Logo, Pascal, BASIC, Eiffel, Smalltalk, Scheme, Modula, Lisp, Erlang, Ada, Fortran, COBOL, SNOBOL, Forth, Algol — All programming languages! (To name just a handful.)