Thursday, April 14, 2011

Programming Levels

As I mentioned in the article Introduction to programming, programming languages ​​must be translated into machine language so the computer can interpret and execute. However, there are variations between machine language and these variations should be taken into account in the first programming languages ​​that were developed. This set of programming languages ​​implies that the programmer (the person writing the program) knows characteristics of the computer for which he or she write the program. These languages ​​are called of low-level, because they have a strict equivalence with the machine language.

On the other hand there are high-level languages, which allow us to write programs independently of the machine to be executed. Finally mixed languages ​​are those that allow us to ignore the details and in the high-level languages​​, but if we can take control of these details and in the low-level languages​​.

An example of a low-level language is Assembler, an example of a high-level language is C#, and finally C++ is a typical mixed language.

Interpretation Form

There are two ways that a computer can understand a programming language:

  1. The first is through a full translation of the programming language into machine language specific to the machine, we will call this technique native code. When using native code there is no guarantee that the program when copied to another computer will still work. But we get the best performance on machines where it works.
  2. After the native code, the next option is using an auxiliary program that translates programming language or other intermediate language to machine language in real time while running, this has the disadvantage of being slower than native code. But this technique can transport the program to other platforms without major complications (says the program is portable to other platforms, or just portable).

    In the latter technique there are two variants:

    1. In the first variant, the program is in the original language it was written and is not verified if it is correct until it is executed, this is called interpreted code, which is evident as it is unsafe because there is no guarantee program integrity (assurance that has not been damaged).
    2. The second alternative is to translate the programming language to an intermediate language that is more easily translated into machine language, this means also to verify if the program is correct before you start to run. In this way the program runs faster and more securely than interpreted code, this will call managed code. Managed code ensures the integrity of the program, however it is possible that even the intermediate language is high level and therefore need another iteration of translation. This second translation is generally performed because the integrity of the program has already been verified, when performing this combination of techniques is still managed code, but if he says it is compiled JIT (Just In Time).

The following are examples of common programming languages ​​compiled to native code: Assembler and C++. On the other side are Java and C# are managed code in most cases, an example of interpreted code (although it might not) is JavaScript. A situation in which JavaScript is not interpreted is the virtual machine V8 using Google Chrome, with this virtual machine JavaScript runs as managed code. There are also tools for compiling languages ​​that are commonly managed code to native code.

No comments:

Post a Comment