The Language

It was exciting to see our first ‘hello’ program running, that wasn’t very hard either, programming seems quite easy after all.

Maybe we can write a game with that technique?

The answer is yes and no. Yes, we can write a simple game with what we learned so far. No, it can’t be a fancy game if we use the programming language that basically does what we can do in a terminal.

We already learned that in order for computer to understand our program, we need to use certain language. Computer can understand many different type of languages, we need to pick one for ourselves.

So what options do we have?

There are many programming langues available, it is nearly impossible to master all of them. The good news is that most programming languages are conceptually the same, if you master one, it will be easy to learn the next one.

We already learned that CPU understands certain instructions, various programming languages are designed to supply CPU those ‘instructions’, as it would otherwise be difficult to directly work with CPU instructions. In order to ease the talking to CPU, there are two different approaches,

Write to Run Language

With this type of programming languages, we can write the program to a file, then give the file executable permission, the file becomes a runnable program!

This is what we did with ‘hello’ program.

There are many different types of languages that work like this, the one ‘hello’ program is written with is called ‘shell script’. Shell script can do complicated things, but basically it is just a way of grouping commands that we can type on a terminal. It is a good choice when we want to automate things.

Some of the languages in this group can do fancier stuff, like drawing on screen, plot curves etc. ‘Python’ or ‘Perl’ are both good and powerful ones.

Compile to Run Language

With this type of programming languages, the files we write are called source files. But source files themselves can not run. We have to use some special tools to ‘compile’ them and generate different files as runnable program. C, C++, Java are popular ones in this group.

What is the difference between the two? why the “compile to run” one even exists? why we add the extra ‘compile’ step?

There can be many differences, depending on what languages we compare between. The primary difference is performance, the ‘write to run’ ones rely on certain interpreter to understand the instructions in the program and run them. The interpreter itself is a program, which runs on CPU. So basically the interpreter is a middle man between the program and the CPU. The ‘compile to run’ ones though, removes the middle man. The ‘compile’ step will turn the program into instructions that can be understood and run directly by CPU.

Ok, the above is an overly simplified description. Java, for example, even after been compiled, it does not directly run on CPU, instead it runs on some virtual machine. We’ll learn all that when we get to learn Java programming. Some languages may not fall into any of the above groups. But it is good for now to remember these two, and their primary differences.

Programming languages are designed to handle different type of tasks. For example, when trying to automate some commands that we have to type on terminal over and over, we may choose shell script. If we need to directly work with hardware, we may use C language.

Programming languages are also designed to be ‘portable’. For example, if we need to write program that can run on more than one operating system (recall that our program has to run in certain OS?), we might choose a language that can ‘program once, run everywhere’. Java would be a good fit.

So what we’ll be learning here? we’ll start with the very basic, yet powerful one, C language …