What is coding?

So, coding… what exactly is it? Well, on a technical level, coding in computing terms is a type of programming which closely or exactly represents how a processor handles instructions. These instructions are stored as binary, sequences of ones and zeros which is base 2 (humans generally work in base 10) that are split into sets or multiples of eight (octets) known as bytes. Here is how binary would look in the least human-readable form:

00000001 00101010 01000000 00100100

Reading long strings of ones and zeros is obviously not very easy for the human reader, and even the best coders would stuggle to trace and solve problems when they arise especially as even the most simple computer programs will consist of thousands of bytes. A more human-readable form is needed, and the next step up from this is hexadecimal. Using the above example (for each byte above) this would be:

01 2A 40 24

Despite being an improvement, remembering what every byte means to the computer is still quite a challenge. So all computer processors have a set of mnemonics in a language called assembly. Again using the above example, in MIPS assembly, this would be:

and $t0, $t1, $t2

Although still cryptic, we have at least introduced an English word in there, ‘and’, which is a logical operator. People familiar with electronics will be aware of gates, and this example is a logical ‘and’ operation that takes the contents of the temporary variable space t1 and t2 and passes it to t0, so $t0 = $t1 & $t2. BUT PLEASE DO NOT WORRY ABOUT THIS! Your children will not be learning coding as has been suggested, they will undoubtedly be learning programming which is a much more human-readable way of doing things, and although it may sometimes be quite cryptic it is nothing like real coding.

The real question, then, is what is programming?

Programming is a method of writing code in a high level (human-readable) form. Most programming languages today use compilers, that is the source (written as a script) is compiled to computer code as described above. This is packaged in a way that can be executed by the computer, for instance, as executable files. Today, these are usually handled by the computer’s operating system, such as Windows EXE files (or even by the operating system on your smart phone or tablet device). Here is an example of a simple program in the language C:

#include <stdio.h>
#include <conio.h>

// My first program in C
int main()
{
    int x = 10;
    int y = 12;
    printf("%d + %d = %d", x, y, x + y);
    _getch();
    return 0;
}

Let’s not worry about the exact langauge for a moment, what does it do?

At the top of the program is the #include directive. It tells the compiler what to include in the final executable. In this case, stdio is standard input/output handling and conio is console input/output. Next we have a comment denoted by // - this is ignored by the compiler and is used simply to enhance readability. Comments are useful when revisiting a script after some time.

The int main() is the main entry point, and we’re declaring it as a type integer. Don’t worry about this for now, simply know that this is where your program will begin, even if your main is at the end of your script. But again this is nothing to get concerned over.

After the int main() is an opening brace, everything within the first { and the last } is where to put your commands.

The first thing we’re doing is declaring two variables, one named x and one named y. They are both of type integer (again, don’t worry about this for now), and we’re making x equal to 10 and y equal to 12.

Now we’ve declared the variables, we’re going to do something with them, and in this case simply add them together. We’ll do this on the fly (you could declare another variable of type integer called answer and make that equal to x plus y if you wanted) and output it to the console window. This is done with the printf command. Everything between the opening and closing bracket after the printf command will be printed to the console window. In between the opening and closing quotation mark, you’ll see the rather cryptic %d - this simply means format the corrosponding variable as a decimal value. The + and = in the quotes are there for presentation, and everything after the closing quote to the closing bracket corrosponds to each %d within the quotes. So it will output:

10 + 12 = 22

The _getch(); command means ‘get character’ - basically, it will wait until there has been a keyboard input, and return zero will in this case simply exit the program returning the value zero.

Obviously, this is something very simple, a starting point, and going from here to building an Android app or a complex and secure website is not going to happen quickly.

Something that I should point out is about the language, and which computer language or languages are best to learn? As important the syntax of a particular language is, programming is not just about the language. The language is a means to an end and generally speaking programming principles do not change from one, say C or C++, to the next, say PHP: Hypertext Preprocessor or Ruby, even if the syntax might be different.

That’s all for now. I will get on to how to write simple programs at another point in various languages. If you have found this interesting, helpful or informatitive, twitter me. Leave feedback. And if your child shows an interest in programming then there is plenty of help out there so don’t panic.