C++

Computers understand only a very limited set of instructions, and to get them to do something, you need to clearly articulate the task using those same instructions. A program (also “application” or “software” or “software”) is a set of instructions that tell the computer what to do. The physical part of the computer that executes these instructions is called hardware or hardware (eg, processor, motherboard, etc.). This lesson is the beginning of a series of lessons on programming in the C ++ language for beginners.

Machine language
The computer’s processor is not able to directly understand programming languages ​​such as C ++, Java, Python, etc. A very limited set of instructions that a processor initially understands is called machine code (or “machine language”). How these instructions are organized is beyond the scope of this introduction, but two things are worth noting.

First, each command (instruction) consists only of a certain sequence (set) of digits: 0 and 1. These numbers are called bits (abbreviated from “binary digit”) or binary code.

For example, one x86 architecture machine code instruction looks like this:

10110000 01100001

Second, each set of bits is translated by the processor into instructions to perform a specific task (for example, compare two numbers or move a number to a specific memory location). Different types of processors usually have different instruction sets, so instructions that will work on Intel processors (used in personal computers) are more likely to not work on Xenon processors (used in Xbox game consoles). Earlier, when computers were just beginning to spread on a massive scale, programmers had to write programs directly in machine language, which was very inconvenient, complicated and took much longer than now.

Assembly language

Since programming in machine language is a specific pleasure, programmers invented the assembly language. In this language, each command is identified by a short name (rather than a set of ones followed by zeros), and variables can be manipulated through their names. This makes writing / reading code much easier. However, the processor still doesn’t understand assembly language directly. It also needs to be translated into machine code using assembler. An assembler is a translator (translator) that translates code written in assembly language into machine language. On the Internet, assembly language is often referred to simply as “Assembler”.

The advantage of the Assembler is its performance (more precisely, the speed of execution) and it is still used when it is critical. However, the reason for this advantage is that programming in this language is adaptable to a specific processor. Programs adapted for one processor will not work with another. In addition, to program in Assembler, you still need to know a lot of not very readable instructions to perform even a simple task.

For example, here’s the above command, but in assembly language:

High-level programming languages
High-level programming languages ​​have been developed to address issues of code readability and excessive complexity. C, C ++, Pascal, Java, JavaScript and Perl are all high-level languages. They allow you to write and execute programs without worrying about code compatibility with different processor architectures. Programs written in high-level languages ​​must also be translated into machine code before being executed. There are two options:

compilation, which is performed by the compiler;

the interpretation that is performed by the interpreter.

A compiler is a program that reads code and creates a stand-alone (capable of running independently of other hardware or software) executable program that the processor understands directly. When the program starts, all the code is compiled in its entirety, and then an executable file is created, and when the program is restarted, no compilation is performed.

Simply put, the compilation process is as follows:

An interpreter is a program that directly executes code without having to compile it into an executable file before. Interpreters are more flexible, but less efficient, since the interpretation process is repeated every time the program is started.

Any programming language can be compiled or interpreted, however, languages ​​such as C, C ++, and Pascal are compiled, while “scripting” languages ​​such as Perl and JavaScript are interpreted. Some programming languages ​​(like Java) can be both compiled and interpreted.

No Comments

Sorry, the comment form is closed at this time.