Computer programming, the basics

The Mystery Of The Code

Inside all computers are a bunch of switches. Like a light switch that can be turned on or off each switch in a computer has a value of 1 for on or 0 for off. What makes the technology of a computer so impressive is that there are billions of switches in the computer and those billions of switches work together to create amazing things. All of the complex control of those billions of switches is done by computer code called binary and it looks like a very long line of 1's and 0's that go on and on and on. Humans cannot deal with binary directly so we have programming languages that allow us the ability to program computers using human readable words, we call these words code or programming code. The code can be written in many different code styles, we call these styles languages. Just like some people speak English and other people speak other languages, computer code comes in many different languages. One of the most popular code languages is C. It was created in 1972, was very popular and still is today. C is very powerful but takes a lot of skill to master. Many programming languages in use today use code style similar to that of C. You could think of C as being the grandfather of many of todays programming languages including Perl.

C code language style
void MyFunction()
{
    for(int A = 0; A < 10; A++)
    {
        printf("Hello world line %s\n", A);
    }
}
Perl code language style
sub MyFunction
{
    for($A = 0; $A < 10; $A++)
    {
        printf "Hello world line %s\n", $A;
    }
}

Both of these examples are a loop called a for loop that will count to 10, one count at a time and each time it will print a line of text and the value of the counter.

Perl, like C, is a procedural programming language meaning that each line of code is an instruction and each instruction is acted upon one at a time until the code ends. Unlike C, Perl does not get compiled to become binary. A program written in C code will use a compiler program to turn the human readable C code into computer readable binary before you will have a program you can run, this process is called compiling. A program that is compiled from C code cannot be read by humans, you can only read the source code that was written in C and often times a programmer will not give you the source code only the binary. Perl is not like that, Perl is not compiled, Perl is a scripting language, meaning that the program you run is the code itself. You may ask, "How is that possible? I thought computers did not know how to read human code only binary." and that is true, but what Perl has is a script interpreter engine. The script interpreter engine works like a compiler to translate human readable text code into computer readable binary code but it does it at run time, when the programs is called to start running.

The advantage of a script language like Perl is that it is easy to debug because you can change the code and run the program to immediately see the difference your changes made. The disadvantage is that script programs run slower then binary programs making it hard to create extremely large or task intensive programs using scripts.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License