You are here

Code translators--Part 3

Amr M. Kamel's blog - Fri, 17/08/2007 - 4:12pm
This is the last part of the Code translators series. In this post I will show you the Hybrid model (Hybrid Compiler-Interpreter Model) and how it did (tried to) overcome the disadvantages of both methods of code translation. You can read the first two parts here and here..

The rise of Virtual Machine:
People think of a way of writing portable code, cause the process of porting applications to various platforms is a tedious and hard process, a code where you can only write once and run it anywhere. They came up with a brilliant idea the Virtual Machine idea. Simple its idea is why not write code and compile it into an intermediate format that a certain Virtual Machine can understand, and can translate it some how to native/machine code??? So now you will not write code that is platform dependent actually it will be independent, it only depends on the Virtual Machine and on which platforms it is supported (this is the only limitation). Think of a Virtual Machine as an intermediate layer between your application and the underlying Operating System.
Now Virtual Machine is considered one of the basic requirements of a scripting language e.g. Python.

Hybrid Compiler-Interpreter Model:
The Hybrid Compiler-Interpreter Model is based on the Virtual Machine idea. This model functionality is composed of two procedures:
  1. First the source code is compiled into an intermediate format rather than native/machine code, usually this intermediate code is optimized and compact.
  2. The Virtual Machine takes this intermediate code and interpret it.
Obviously this model overcomes the slowness of interpreted languages, and try to reach good rate of performance much like compiled languages. Also it overcomes the platform dependency problem presented by compiled languages.

Off-topic note: That is the beauty of computing you have two ways of doing a thing and you are not satisfied by both, so you combine them you get something more powerful "more satisfaction but not 100%, well nothing is perfect !! ;)" its much like Pretty Good Privacy (PGP), it uses combination of symmetric and asymmetric cryptographic systems :D.

Just In Time (JIT) compiler:
The JIT (Just In Time) compiler is an enhancement to the Hybrid Compiler-Interpreter Mode. The JIT compiler replaces the functionality of the Virtual Machine "but its still called Virtual Machine", the JIT compiler takes the intermediate code and it compiles code into processor instructions and runs that instead of interpreting the code. This will lead to faster run-time performance and still keeps the code portability feature. This model is adopted by many programming languages like Java and Microsoft Dot Net.

Well thats all folks, I wish you enjoyed this series as much as I did, and I hope that it may have an added-value to your knowledge ;). Of course any comments are welcomed.