Todays computers are incredibly fast, and getting faster all the time. Yet with this speed comes some significant constraints. Computers only natively understand a very limited set of instructions, and must be told exactly what to do. The set of instructions that tells a computer what to do is known as software. The computer machinery that executes the instructions is the hardware.
A computer’s CPU is incapable of speaking C++. The very limited set of instructions that a CPU natively understands is called machine code, or machine language, or an instruction set. How these instructions are organized is beyond the scope of this introduction, but it is interesting to note two things. First, each instruction is composed of a number of binary digits, each of which can only be a 0 or a 1. These binary numbers are often called bits (short for binary digit). For example, the MIPS architecture instruction set always has instructions that are 32 bits long. Other architectures (such as the x86, which you are likely using) have instructions that can be a variable length.
For example, here is a x86 machine language instruction: 10110000 01100001
Second, each set of binary digits is translated by the CPU into an instruction that tells it to do a very specific job, such as compare these two numbers, or put this number in that memory location. Different types of CPUs will typically have different instruction sets, so instructions that would run on a Pentium 4 would not run on a Macintosh PowerPC based computer. Back when computers were first invented, programmers had to write programs directly in machine language, which was a very difficult and time consuming thing to do.
Because machine language is so hard to program with, assembly language was invented. In an assembly language, each instruction is identified by a short name (rather than a set of bits), and variables can be identified by names rather than numbers. This makes them much easier to read and write. However, the CPU can not understand assembly language directly. Instead, it must be translated into machine language by using an assembler. Assembly languages tend to be very fast, and assembly is still used today when speed is critical. However, the reason assembly language is so fast is because assembly language is tailored to a particular CPU. Assembly programs written for one CPU will not run on another CPU. Furthermore, assembly languages still require a lot of instructions to do even simple tasks, and are not very human readable.
Here is the same instruction as above in assembly language: mov al, 061h
To address these concerns, high-level programming languages were developed. C, C++, Pascal, Ada, Java, Javascript, and Perl, are all high level languages. Programs written in high level languages must be translated into a form that the CPU can understand before they can be executed. There are two primary ways this is done: compiling and interpreting.
A compiler is a program that reads code and produces a stand-alone executable that the CPU can understand directly. Once your code has been turned into an executable, you do not need the compiler to run the program. Although it may intuitively seem like high-level languages would be significantly less efficient than assembly languages, modern compilers do an excellent job of converting high-level languages into fast executables. Sometimes, they even do a better job than human coders can do in assembly language!
Here is a simplified representation of the compiling process:

An interpreter is a program that reads code and essentially compiles and executes (interprets) your program as it is run. One advantage of interpreters is that they are much easier to write than compilers, because they can be written in a high-level language themselves. However, they tend to be less efficient when running programs because the compiling needs to be done every time the program is run. Furthermore, the interpreter is needed every time the program is run.
Here is a simplified representation of the interpretation process:

Any language can be compiled or interpreted, however, traditionally languages like C, C++, and Pascal are compiled, whereas “scripting” languages like Perl and Javascript are interpreted. Some languages, like Java, use a mix of the two.
High level languages have several desirable properties. First, high level languages are much easier to read and write.
Here is the same instruction as above in C/C++: a = 97;
Second, they require less instructions to perform the same task as lower level languages. In C++ you can do something like a = b * 2 + 5; in one line. In assembly language, this would take 5 or 6 different instructions.
Third, you don’t have to concern yourself with details such as loading variables into CPU registers. The compiler or interpreter takes care of all those details for you.
And fourth, they are portable to different architectures, with one major exception, which we will discuss in a moment.

The exception to portability is that many platforms, such as Microsoft Windows, contain platform-specific functions that you can use in your code. These can make it much easier to write a program for a specific platform, but at the expense of portability. In these tutorials, we will explicitly point out whenever we show you anything that is platform specific.
0.3 — Introduction to C/C++
|
Index
|
0.1 — Introduction to these tutorials
|
0.3 — Introduction to C/C++
Index
0.1 — Introduction to these tutorials
So Detailed, and easy, and informational, and helpful, and FREEEEEEE!!!!!!!!
thank you ….helpful……
I’m probably gonna comment every single thing as I learn this. Just to show my gratitude to this website.
Even this first chapter is amazing.
OK
This topic is amazing
Sweet!
ill probably comment on every single one too. Without this, I probably wouldn’t learn computer languages until 12th grade! Screw that!!
I’m gonna start remembering C++ programming by reading this tutorial and, according to the comments, I have to say that looks pretty good! Good job and most of all it’s really updated
Hey There,
I’ve been doing programming for years and have never bothered to learn more than the academics of what the real “guts” where. This tutorial was very easy to understand and makes we wanna get back down into lower level programming.
Very well laid out and informative. Keep up the good work :)
, Mike
This tutorial continues to amaze me. Just more ways for me to refine my skills.
I LOVE this website. I needed to learn how to code in C++. Is there a similar site like this to learn Java?? I need to learn that, too :)
Jack
Try http://www.w3schools.com
(www.w3schools.com/js/default.asp)
Very nice en good information. Thanks.
Are there any CPUs who understand each others instructions written in high-level language code? Or in other words, are build
execuatbles compatable for certain CPUs and platforms?
Niels
To my knowledge, no CPU understands instructions written in a high-level language. Because of the fact that each CPU only understands specific instructions that are native to it, high-level language programs must be compiled into CPU-specific machine-code. This means executables are not natively cross-CPU.
Hi,
IS there a similar site for learning JAVA also ?
I’m sure there is, but as I am not a java programmer, I am not personally aware of one. Perhaps another reader might be of assistance here.
Raja, to the best of my knowledge, I do not think so (except for maybe the official Java tutorial from sun).
However, if you are not afraid of digging in, check out Bruce Eckels book “Thinking in Java”. As of current, the third edition can be freely downloaded from his webpage (www.bruceeckel.com). This is a fantastic book that I personally value at top-level. Eckel also has two books on C++ (Thinking in C++, vol I and II), which you also may download from his site. Beware that they go deep though! How you use them is up to you. This tutorial is much more concise I think, whereas Eckels book deals with much more smaller details and technicalities (forgive me if I misspelled that!).
Having said that, this website is by far the best tutorial I have seen online on C++, and using it in conjunction with Eckels book and an education can be a killer combination.
Nice!
I am now porting to section 0.3 to compile some extra knowledge for my brain to interpret
Thanks!
so easy concept
hello sir i like your website which is very helpful and carry great information
i found a mistake please correct it in interpreted languages you said Perl and Java may be you intend javascript …. java is complied type language
[ I did mean Javascript. I clarified the example. Thanks! -Alex ]
A minor error:
In the text there’s an example of machine language
and assembler
but the C/C++ example
should be a = 97;
[ Fixed. Thanks for noticing. - Alex ]
Does anyone know where I can get a reliable compiler?
Bob – I use Code::Blocks as my C++ IDE, and its available with a GCC compiler and GDB debugger from MinGW. Its free and I’ve always found to be fairly reliable. I beleive you can also add addition compliers if you require them.
I talk about several options in lesson 0.5 — installing an integrated development environment.
Its really good ,very easy understandable tutorial , thanks to the site admin .
THis is an amazing website..So easy for the first timers like me to understand..
Can anybody tell me if there is any website like this for Microsoft SQL server ..
I love Guys!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
OMG!!!! Like I love guys too!!!!!!!!
this is good for biginers…..
very good nice info dude
Very informative, I like this tutorial. Will post everytime I’ve read a part. This one covered a lot, thanks for giving this for free.
hey
i am walid from lebanon
Thank you…Every thing is Ok.
I’m from Ethiopia, The East and horn of Africa.
you are absolutely amazing!!! before finding this i was on the verge of crying!!! this is the best tutorial ever!!! keep up the good work!!!
and may i ask if it would be possible for you to provide us with more tutorials on other programming languages???
thanks!
Hii alex..do u hv this type of tut for java?
sooooo sweeeet ov u guys
—> This link: http://vinodmuda.webs.com
Does your copyright cover this? =/
I am trying to learn how to program MUD and this is helping so much with the C++ part :)
Very useful and simple to understand :) Thanks!
How awesome this is. Thanks for the work done.
It is very easy and well detailed tutorial. I will keep following till the end.