Classification of computer languages (III)

Tags: devlive, computerscience, webdev, software
Published: 2020-04-15 22:15:18


We have been analyzing the ways of classifying computer languages, today we will continue with the classification by translation and method of execution. If you want to start the thread of these posts, I leave the table of contents here.

| <center> Content </center>       |
|-----------------------------------|
|<center>[**Classification Part I**](https://dev.to/vplentinax/computer-languages-i-24pb)</center>|
|<center>[**Classification Part II**] (https://dev.to/vplentinax/classification-of-computer-languages-ii-2201)</center>|


### **Translation and method of execution**
The code written for a computer program is known as the **source code**. This code is saved in a file known as **source file** and will have to be translated into language machine to be able to run.

Three language groups can be considered programming considering how to translate to machine language and to execute:
- Compiled languages.
- Interpreted languages.
- Managed execution languages ​​or of machine virtual.

Some languages ​​like Prolog can be considered compiled or interpreted since they have compilers and interpreters.

#### Compiled languages

They have a compiler or program that translates the **source code** to **machine code** saving the result in an **executable file**. This compiled code that is generated is called an **object code**. With that file you can run the program as many times it is necessary without having to repeat the process, so the waiting time between executions is minimal. At runtime the executable file is launched on the platform for which the compiler was made.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aetrjqvyxwr0pdmql2pf.png)

|<center>Characteristics</center>|
|----------------|
|There is an executable file for the real machine.|
|The translation process is done at compilation time and only once.|
|Execution is very fast since the executable is in machine language.|
|The executable only works for the platform it was created for.|
|The user who executes does not have to know the source code, he only has the executable code that is not easily manipulated to obtain the source code, and as a consequence the programmer has the code most protected source.|
|The executable will not be generated if there are lexical errors, syntactic or semantic.|
|Interrupting execution can be difficult for the system operational and may affect the platform.|
|Modifying the source code implies going back to generate the executable file.|

Example: ADA, C, C++, COBOL...

We see them more in desktop software since they require greater resources and access to certain files. Also due to the greater weight that they usually have in their executable files.

#### Interpreted languages
They execute the instructions directly, without generate object code. They need an **interpreter** or program in memory to that at runtime the code is translated from source code to machine language. Your instructions or rather the source code, written by the programmer in a high-level language, is translated by the interpreter to a language understandable to the machine step by step, instruction by instruction. The process is repeated every time the program is run, the code in question.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qnvxgh97fmifv7182341.png)

|<center>Characteristics</center>|
|----------------|
|There is no executable file.|
|The translation process is done every time it is run.|
|The execution is slow since the execution process the translation has to be added.|
|The file can be run on different platforms provided there is an interpreter for them.|
|The user uses the source code to execute program.|
|Lexical, syntactic or semantic errors can appear in the execution|
|Interrupting execution normally only affects to interpreter and not to the platform.|
|Allows dynamic data typing. It is not necessary initialize a variable with a certain data type.|

Example: RUBY, PYTHON, PHP, JAVASCRPT, VISUAL BASIC 6 and previous...

They are seen in the development of applications or websites that go accompanied by frameworks that greatly facilitate the programming.

#### Managed execution languages ​​or machine virtual.
These languages ​​initially need a compiler that in programming time translates the **source code** to a cross-platform **intermediate code**, then you need other software that translates that intermediate code to machine code. This is the case of languages ​​like Java or .NET

In the case of **virtual machine languages** ​​such as **Java** happens that:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8r65vondkeq70gzb7evy.png)

- At compile time the Java compiler generates the intermediate code called **bytecode** Java platform independent.
- At runtime, you need a **Java Virtual Machine (JVM)** that interprets the bytecode, virtual machine is a software that simulates a machine
real with your operating system.
- It acts as an intermediary with the real machine, so virtual machines are different for Linux, Windows, Mac and Solaris.
- This scheme provides many of the advantages of
compilation and interpretation, getting rid of some drawbacks. Mainly:

|<center>Virtual Machine Advantage</center>|
|----------------|
|**Portability** and **speed:** The intermediate code is now free of syntactic errors, and it is a very simple code (in the style of machine code).|
|**Multiplatform:** If there is an interpreter for this code in different platforms, the same code can be run on each of them.|
|**Stability:** intermediate code is not executed by a CPU directly, but yes by a virtual CPU: really, by the virtual machine interpreter, which is a program and not a real chip It allows greater control over this code, making work easier to prevent uncontrolled code from affecting stability of the current platform.|

In languages ​​of **managed execution** such as **Microsoft's .NET** platform happens that:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4fk6yjts65xr3jua49b7.png)

- At compile time, the compiler generates the **CIL (Common Intermediate Language)** code of independent platform.
- To run it is necessary to have on the client computer the version of the .NET Framework **(CRL Common Runtime Language - proper execution engine)** and the last compilation phase is done, in which the CRL will translate intermediate code into machine code using a **JIT (Just In Time) compiler**.
- To directly run a .NET application using the CLR, you need the so called **"CLR Hosts"**. **CLR Host** is an application responsible for loading the CLR in an operating system process, create the application domains required within that process and run the application inside the application domains.
- The .Net platform has a common system of types known as **CTS (Common Type System).** All types of data are collected in the CTS and operations that can be used from a language .Net. It doesn't matter if we use Visual Basic .Net, C #, COBOL, Perl or Pascal. The data set to use is always the same. The CTS also includes the operations that can be done on the data.
- There is a subset of the CTS made up of data types and operations that all .Net languages ​​must implement to be compatible with the rest. This subset is known as **CLS (Common Language Specification).**

|<center>Common features between managed machine and virtual machine languages</center>|
|----------------|
|There is an intermediate code that runs on a specific software but not an executable.|
|The initial translation process is done before execution and the final translation process is done every time running.|
|Execution is not as fast as in compiled languages ​​but it is faster than in languages interpreted.|
|The file can be run on different platforms as long as the specific software exists.|
|The user does not have the source code, only the intermediate code that is not easily manipulated to get the source code, so the programmer has more protected source code.|
|Lexical, syntactic or semantic errors are detected in the compilation phase, and if they exist they are not will generate the intermediate code.|
|Interrupting execution normally only affects the interpreter and not to the platform.|
|Modifying the source code implies repeating the compilation process.|

#### Client-server architecture

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tn4ddcawtdekd9eaudqo.png)

The client-server architecture basically consists of a **client program** that **makes requests** to a **server**. It is most useful when the client or the server are communicating through a network, although it can also be apply when they are on the same machine.

It differentiates between languages ​​that are executed: 
- Server-side like PHP, NodeJS...
- On the client side as Javascript...


These were some of the ways of classifying computer languages, I hope you have learned a lot. See you soon.