WARNING: You've somehow managed to stumble upon a WIP document. Feel free to continue reading, but don't come crying to me if you find any mistakes!

What is programming?

Programming is like giving a set of step-by-step instructions to the computer to know both what we want to do and how to do it. It is only by combining these step-by-step instructions along with the computer's ability to do mathematical operations very quickly that we can achieve "smartness" and build software for doing interesting things.

Step-by-step instructions

I personally like to think of programming much like the process of giving turn-by-turn navigation to someone trying to get from point A to point B:

Navigation from point A to point B

In this example, if we wanted to give the turn-by-turn instructions from point A to point B (assuming each square to be a city block), we could say something like:

  1. Head east for two blocks
  2. Turn left and head north for another two blocks
  3. Turn right and head east again for another block
  4. Turn left and head north for one last block and you'll arrive at your destination

Sometimes though, it becomes tedious to give very specific instructions such as "walk 8 blocks" because sometimes we don't even know precisely how many blocks there are:

Navigation from point A to point B (again)

In this example, assuming we didn't know exactly how many blocks were after that first left turn, we might get creative and say something simpler:

  1. Head east for two blocks
  2. Turn left and head north until you arrive at your destination

By using this new way of describing directions, not only have we made the directions more concise, but we've also, in a sense, made them more forgiving (we might have otherwise given the wrong directions if we tried using an exact number of blocks to travel before stopping).

Exercise #1

Now it's your turn! Using no more than 2 instructions, give the steps you'd list out to someone trying to get from point A to point B (hint: it may be useful to use the intermediary point a):

Navigation from point A to point B (exercise)

  1. Head east until you arrive at point a.
  2. Turn right and head south until you arrive at your destination

Click to reveal answers

Programming languages

Programming is often done by using a special language, quite suitingly called a programming language, to create a set of instructions, called a program. The program is then given to the computer which typically will interpret the program's contents to perform whatever function is desired.

Just as in human languages, a programming language is made up of a vocabulary, grammar, syntax (for example, punctuation), and semantics (what actually makes sense in a sentence?). Similarly, in the above navigation examples, the programming language can be thought of as:

Vocabulary
Turn (verb), left/right (noun), head (verb), north/south/east/west (noun), walk (verb), etc.
Grammar
Sentences are made up of a verb followed by a noun
Syntax
English syntax
Semantics
The verb "turn" should only be followed with a direction ("left" or "right"), etc.

Different kinds of programming languages

As you might have guessed, not all programming languages are the same. Some use a different vocabulary with made-up words. Some use a grammar that looks nothing like English. Some use bizarre punctuation all over the place. And some even have semantics whose meaning changes depending on context.

You might be wondering, "Why would you use one programming language over another?" Generally speaking, not all programming languages are built to be able to solve all problems. For example, some languages might be easier to use for building a web page, others maybe better suited for mathematical computations, etc.

Blockly is an example of a programming language that both has a unique language and has a fairly specific purpose. Firstly, it is a visual programming language which means the vocabulary used in this language is represented with visual components (in this case, blocks). Furthermore, the grammar of the language allows a programmer to only put blocks together in certain combinations, much like the pieces of a puzzle. Blockly was created specifically for the purpose of teach new programmers how to solve problems using a programming language.

Exercise #2

Click here to solve the navigation puzzles using the Blockly programming language.

Now that we know what programming is and have a rough idea of how we describe a program to a computer, let's continue our journey with our first look at how to get the computer to do something for us!