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.
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.
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!"
Clearly 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:
- Selection —
- Iteration —
- 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
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
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.
CSS do not have any of the three required elements of a programming language. They are computer languages, but not programming languages.
HTML — Hyper-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.)
CSS — Cascaded Style Sheets. A computer language for inserting text formatting meta-data into an HTML document.
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.)
Reblogged this on SutoCom Solutions.
Going back a bit in time when a full Word Perfect word processing package was written in 10K of code, makes me appreciate the the growth of languages and the power of scripting but also their differences.
As an aside: The power of the processor and software libraries has allowed us to do amazing things computationally but it doesn’t make us efficient at executing machine instructions from languages and scripts. We are locked into relying on how well those software libraries, compilers/cross-compilers and interpreters/engines are written in the first place and then by how they are implemented. We won’t go into the languages/scripts and how well they are used by programmers to do the task will we. I would never go back to low level programming and love multimedia but I must admit it was a heck of a lot of fun writing in Assembler or FORTH. One appreciated how dumb a processor/s is but also the wonder of telling it very directly what to do, how and when – was also a good lesson in efficiency when programming in a higher language or script.
Wyrd Smythe said:
Like you, I go back to the early days. I started in 1977, and I still have some of my first BASIC programs… stored on 7-bit punched paper tape. So I can totally relate to what you say about bloat and libraries. I remember installing my first 5-meg hard drive and thinking, “Gee, this is great. I’ll never fill this sucker up!” XD
I’ve written compilers and designed programming languages and I’ve used every language you named (and many more). I thought Forth was a hoot, and used its idea of a parameter stack in BOOL, a language I designed (which steals from all my favorite languages 🙂 ). If you liked Forth, and have never tried Lisp or Smalltalk, I recommend them. Until Python, no language delighted me so much as Lisp. And Smalltalk is a mind-bender!
It’s also a programming language. It has selection, iteration, and variables. It’s almost certainly Turing Complete. That makes it a programming language pretty much by definition.
I think you’re trying to say it’s not a great programming language, although that’s a matter of opinion. ECMA 262 really isn’t all that bad a language. It’s used as the automation language in a number of systems, and it does just fine there. It is something of a special-purpose language rather than a general-purpose one. And while it may not be the most powerful, or the most expressive, programming language, it’s still a programming language.
I’d definitely take JS over Forth or Pascal or COBAL or FORTRAN or C or even C++. I consider those dead languages given what’s available today.
In fact, until I got into Python, it was the language I recommended as a good first language for beginners. It’s fairly simple to learn, fully object-oriented, and due to its relationship with browsers you can do fun things with it almost immediately. And knowing it ain’t a bad bullet point on a resume given its market penetration.
Wyrd Smythe said:
p.s. One thing we might totally agree on: programmers who learned to write good assembly usually make superior programmers in high-level languages. As you say, it provides crucial understanding of the underlying machine.
Pingback: WP: Classic Editor vs Reader | Logos con carne