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.
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:
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:
- Head east for two blocks
- Turn left and head north for another two blocks
- Turn right and head east again for another block
- 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:
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:
- Head east for two blocks
- 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).
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):
- Head east until you arrive at point a.
- Turn right and head south until you arrive at your destination
Click to reveal answers
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:
- Turn (verb), left/right (noun), head (verb), north/south/east/west (noun), walk (verb), etc.
- Sentences are made up of a verb followed by a noun
- English syntax
- 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.
Click here to solve the navigation puzzles using the Blockly programming language.