Programming Languages

If you want to learn about programming, you first need to know about programming languages.

A programming language is human-readable code that is written by the programmer. It’s main property is to be understood by humans while the computer doesn’t understand it at all. Computers use machine-readable code to understand what they need to do. As computers these days work in a binary system, they can only understand two different states: 0 and 1. In a computer, everything is ruled by zeros an ones which is the only logical way to work for a machine, but not for humans. As this is causing a communication problem for the programmer, there is a tool that can translate human-readable code into machine-readable code. This tool is the compiler.

The compiler translates the instructions that the programmer is writing into zeros and ones so that the computer understands what you want. So the basic steps are: the programmer writes the code, he compiles it and then the computer can execute it. Depending on the compiler and the length of the code, this can take seconds, minutes or even hours. In order for the compiler to translate the code, it is important that the code is written in a very specific manner including keywords that need to be used, a structured syntax how to present the code and a certain consistency of certain patterns. These things combined form a programming language.

Each language has slightly different elements that make the language unique. This can be the keywords, the syntax or the way the compiler translates the code. Each language will therefore require its own compiler in order to work.

Probably the most prominent programming language is the C Programming Language, or C for short. It has been developed by Dennis Ritchie and it is used for programming operating systems, software for computers and even for hardware. An important extension to the C language is C++ (called C-plus-plus) developed by Bjarne Stroustrup. Those languages are quite similar to each other and have the advantage of fast execution once the program has been compiled. The disadvantage is, that they require a steep learning curve and long development times due to the fact that you need to manage everything on your own and the program need to be compiled before execution.

Another language that has become extremely popular is called Python and has been developed by Guido van Rossum. This language is not compiled but interpreted instead by a interpreter. The interpreter is a program that will translate the human-readable code during the execution of it. This makes the development process much faster as you don’t have to compile the code before testing it. At the same time, Python is simplifying the programming process a lot as it will take over some tasks automatically (such as memory allocation, etc. ). Unfortunately, this results in slower software when running it compared to a compiled language. Python is very easy to read and write compared to C and therefore it is often recommended as the first programming language for becoming developers.

Below, you will see an example how a program will look like when using the C language. The example shows the Hello World program written in C. This is often considered as the easiest example of a valid program and often used to demonstrate the syntax of a program.

#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}

Now you can compare this to the Python version of the same program.

#!/usr/bin/env python
print "Hello World"

As you can see, there are quite some differences. A small side note: programming languages develop over time and get new features in each new version. This means that each version will have some differences. The Python code above is written following the rules of Python 2.7 while the latest version Python 3.8 will have a slightly different syntax.

This guide will mainly focus on covering Python 2.7 as it is used in many applications even though it is not the latest version. (Some people just never wanted to switch over to the newer version and keep using 2.7 instead.) Also, the Robot Operating System (ROS) is also using version 2.7 of Python.

Continue learning more about variables or go back to the overview.