NOTE: To use the advanced features of this site you need javascript turned on.

Home Knowledge Base Software Translation Compiled Execution

Compiled Execution

The purpose of programming languages is to facilitate the communication of algorithms to the computer. Programming languages are tools for programmers and represent a formal notation to express algorithms. An algorithm is an abstract concept, independent of any notation, but without a notation it is not precisely expressed or communicated to others, and verifying it is quite difficult.

The communication interface with the computer is a binary language, difficult to grasp for the human mind, called machine language. Machine language is binary because the internal structure of computers is binary. Various architectures and different CPU types imply a variety of machine languages, normally incompatible with each other.

From the theoretical point of view a machine language is a descriptive language whose sentences are not produced by a generative language. By contrast, usual programming languages are different from machine language because they are generated by context independent grammars.

That is why, when passing from a programming language to a machine language it is needed to translate sentences built in the programming language into machine language sentences that make sense for the hardware. This process is called compiling and the software tool that makes this process possible is a compiler.

Consider the following code sequence expressed in Java™:


int[] vector = {6,1,89};
int sum = 0;

for(int i=0;i<vector.length;i++){



For the human reader acquainted with Java™, the code means summing all the elements of a vector. For the computer it is only a character sequence like any other. The Java™ compiler transforms this source code into machine code executable on the Java™ platform.

The assembly language equivalent of the machine code sequence generated by the Java™ compiler is:


0:	iconst_3
1: newarray int
3: dup
4: iconst_0
5: bipush 6
7: iastore
8: dup
9: iconst_1
10: iconst_1
11: iastore
12: dup
13: iconst_2
14: bipush 89
16: iastore
17: astore_1
18: iconst_0
19: istore_2
20: iconst_0
21: istore_3
22: iload_3
23: aload_1
24: arraylength
25: if_icmpge 40
28: iload_2
29: aload_1
30: iload_3
31: iaload
32: iadd
33: istore_2
34: iinc 3, 1
37: goto 22
40: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
43: new #3; //class StringBuffer
46: dup
47: invokespecial #4; //Method java/lang/StringBuffer."":()V
50: ldc #5; //String Sum=
52: invokevirtual #6; //Method java/lang/StringBuffer.append:
55: iload_2
56: invokevirtual #7; //Method java/lang/StringBuffer.append:(I)
59: invokevirtual #8; //Method java/lang/StringBuffer.toString:()
62: invokevirtual #9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V


This code works with the local stack, with the constant pool and uses methods from other classes. The Java™ virtual machine executes this code and the result complies to the original Java™ instructions.