Make Your Introduction To Programming Easily: Read Or Miss Out

Introduction to Programming

Computers are limited in what they can understand, so in order to get them to perform a task, it is crucial to provide them with clear instructions. Computer programming (also known as software, application, or program) is the process of instructing a computer how to perform certain tasks. It is the hardware of the computer that executes these instructions (e.g., the processor, motherboard, etc.) that is known as hardware. In the following series of C++ programming lessons, we will introduce beginners to the language.

Table of contents:

  1. Machine language
  2. Assembly language
  3. High-level programming languages
  4. Benefits of high-level programming languages

Machine language

Computers cannot understand C ++, Java, Python, etc. directly due to the processor’s limitations. It is called machine code (or “machine language”) that describes only a very limited set of instructions understood by a processor. It would not be appropriate for this introduction to describe how these instructions are organized, but two points are worth mentioning.

The only sequence (set) of numbers in a command (instruction) are 0 and 1. In the simplest form, bits (abbreviated from ” binary Digits “ ) represent this.

The machine code for one instruction on an x86 architecture looks like this:

10110000 01100001

In the second step, the processor translates each bit into instructions that will perform a specific task (for example, comparing two numbers or moving a number to a specific memory location). Intel processors (used in personal computers) often have different instruction sets, so Xenon processors (used in the Xbox game consoles) are likely to fail to execute instructions that will work on Intel processors. Programmers have long created programs in machine language because computers were first introduced to the world, but it was very inconvenient, difficult, and time-consuming.

Assembly language

Assembly language was invented by programmers who loved to program in machine language. The commands of this language are identified by short names (not a set of ones and zeroes), and variables are manipulated via their names. As a result, writing / reading the code became a lot easier. Although the processor can understand assembly language indirectly, it cannot directly understand it. Furthermore, it must be translated to machine code using an assembler. Essentially, an assembly language translator (translator) translates code into machine language. “Assembler” is the term often used on the Internet for assembly language.

Assembler is still used in critical situations because of its performance (or, more precisely, speed of execution). Due to the fact that the language allows for the adaptation to specific processors, it has this advantage. It is impossible to run programs adapted for one processor on another. Assembler programming also requires one to know many not very readable instructions in order to perform even the simplest of tasks.

Here is an assembly language version of the above command:

mov al, 061h

High-level programming languages

To deal with the problems of code readability and excessive complexity, high-level programming languages have been developed. There are a variety of high-level languages, including C, C++, Pascal, Java, JavaScript, and Perl. With them, you can write and execute programs regardless of the processor architecture without worry. It is also necessary to translate high-level languages into machine code before executing them. Two options are available:

  •    The compiler performs the compilation;
  •    It is the interpreter’s responsibility to provide the interpretation.

The compiler is a program that translates code into an executable program that a processor directly understands (capable of running independently from other hardware or software). A complete compilation of all the code occurs when the program starts, and a compiled executable file is then generated for resuming the program.

Compilation involves the following steps:

Compiler Explain

An interpreter executes code directly without the need to compile it into an executable file first. Because interpreters repeat the interpretation process each time the program is started, they enjoy more flexibility but are less efficient.

The interpretation process is as follows: 

Interpreter

It does not matter whether a language is compiled or interpreted, but languages like C, C++, and Pascal are compiled, while scripting languages like Perl and JavaScript are interpreted. It is possible to compile and interpret some programming languages (such as Java).

Benefits of high-level programming languages

First advantage: Writing/reading code is easier. As an example, here’s the C++ equivalent:

а = 97;

Second Advantage:  fewer instructions are required to accomplish a specific task. C++ allows you to do something like a = b * 2 + 5; in one line. It would take 5 or 6 instructions in assembly language.

Third advantage: is that you don’t have to deal with details like loading variables into processor registers. Compilers and interpreters handle this for you.

Fourth Advantage: High-level languages are more portable across various architectures (but there is one caveat).

High level language

For example, Microsoft Windows has many features that make writing code more convenient. In this situation, however, portability is sacrificed. Because functions specific to one platform may not work on another, they may not work across platforms. We’ll talk about all of this in more depth in the next lesson.

LEAVE A REPLY

Please enter your comment!
Please enter your name here