Back to blog
Apr 26, 2024
5 min read

JavaScript as a Language

A high-level overview of what is meant by a "programming language".

This is a published “draft” - I expect to revise it over the next short while.

JavaScript as a Language

JavaScript is a programming language. Before we get into what we mean by “programming”, let’s take a look at what we mean by language.

By Comparison…

Everyone is familiar with the notion of human languages; they are the primary means by which we communicate, both verbally and in written form. Let’s compare human languages (in the written form) to programming languages.

The Pieces of a Language

Human and programming languages make use of individual “pieces” which we can recognize as words, symbols and labels.

Languages have words that are part of the language, and the words have particular meanings or definitions in the language. In the world of programming we call those keywords or reserved words. Human languages can have thousands upon thousands of words, but programming languages typically are made up of a very small set of keywords. JavaScript (as of 2024) has about 63 keywords.

Languages (in their written form) have symbols which help in understanding the meaning of a set of words. Those symbols might be punctuation – a period, exclamation mark, or question mark in English – or the might be some other type of symbol, such as a semicolon (; to denote the idea of “and” or “but”) or ampersand (& to denote the word “and”). Some symbols have mathimatical significance: plus (+), minus (-), etc. In computer programming we call these symbols operators.

Lastly, languages have “special” words that act as “labels” for people, places and things. For example, the name “Edmonton” denotes a place and the name “Fred” denotes a person. What separates these labels from ordinary words is that they point to a particular person, place or thing and that it is possible for the same label to refer to distinct people, places or things. For example, there is a city called “Edmonton” in Canada that is different from the city “Edmonton” that exists in the United Kingdom. (There are actually five cities named “Edmonton” in the world.) In the world of programming, the term identifier is used for things that we label.

As a Whole

We can further press the comparison of human and programming languages by recognizing that the words, symbols and labels are combined in particular ways to convey certain ideas and meanings. What helps form the meaning of a combination of words, symbols and labels is the grammar of the language.

Let’s take a look at a couple of sentences: “That is John!” vs. “That is John?” Here we have two sentences with the same words and labels in the exact same order. Nevertheless, the meaning we ascribe to those words changes just be the use of puctuation. The first example is an exclamation while the second is a question. This example illustrates how punctuation can dramatically affect the meaning of a sentence. Grammar depends, in part, on punctuation.

Grammar also has rules around the order in which we put words. Consider the sentence, “Sally sat on the chair.” The order of the words affects the meaning; take a moment to form a mental picture from that sentence.

Now, let’s change the order: “The chair sat on Sally.” Same words, different order. And a very different mental picture should be forming in your mind.

Grammar is an important part of human and programming languages. As humans, we pick up the grammar rules just by growing up. At the same time, we can study grammar in school so that we are aware of the proper way to communicate in a certain language (particularly in written form). Sometimes the grammar rules are strict, while at other times the rules are held more loosely. They may even be nuanced by tone or formatting. If I say, “That is a great idea!” – notice the italics – I might be talking sarcastically or enthusiastically.

Let’s do a final re-arranging of our sample sentence. Consider the following: “Chair on the Sally sat.” The order of the words breaks the rules of English grammar. We might still get something of an understandable picture, given it’s a human language (try saying it in Yoda’s voice).

For computer languages, grammar rules are far more strict because computers are just “machines”. They can’t “think” like people do (despite the claims of AI). When our code breaks the grammar rules of the programming language, we refer to that as a syntax error.

Back To Your Regularly Scheduled Program

So, JavaScript is a language. We use it for programming – giving the computer instructions to get it to do what we want it to do.