Tuesday, June 3, 2008

More about RapidQ and compilers

Is RapidQ really a compiler ?

Well the answer is 'Yes' and 'No' !! In fact you can call it a pseudo-compiler. The compiler first translates the source code into an intermediate language. This intermediate language is a proprietary language which only (perhaps) William Yu knows! Then the compiler creates an executable files (.exe) by binding an interpreter program with the translated intermediate code. So what you see when you compile a program with the RapidQ compiler is an file with the extension '.exe'. But it contains both the compiled intermediate code plus the intermediate code interpreter. So double clicking the executable file runs the interpreter which in turn loads the intermediate code within the executable file and runs it.

Thus, we can see that RapidQ compiles the source into an intermediate code and then interprets it when run. That is why I answered the question 'Yes' and 'No'.

The regular compilers are those than compiles the source code directly into the machine language of a computer. But the compiled executable program is dependent on the operating system running on the computer on which it runs. There though you may compile you program using a compiler for Windows on an Intel Pentium machine, you will not be able to run the executable on an Intel Pentium machine with Linux as the operating system. To run your program on Linux, you should compile your program using a compiler for Linux operating system.

A compiler vendor may sell different versions of their compiler for Windows as well as Linux. In that case you may take your program's source code and use the compiler version that relates to your operating system to create an executable file. For example, if you have written a program in the C language which only uses the features that conforms to the ANSI C standards, you may be lucky to just use an ANSI C compiler on Linux to compile your source code for Linux without any changes. So to an extent, C is called a portable language. But not fully.

At present the most portable language is Java. Using Java, you can compile your source code into a ".class" file.
This file contains an intermediate code for a virtual machine called the 'Java Virtual Machine' or JVM for short. Note that it is not an executable file as such. It does not have a '.exe' or '.com' extensions but only a '.class' extension. Then how is this 'class' executed ? Well, you need to install a Java Runtime software on your computer. So if you have installed it, then you will be able to run the '.class' file by giving the command 'java yourprogram.class" on your computer. One advantage of Java is, that you can copy the compiled '.class' file directly from Windows to Linux or vice versa and then run it without any modification or tweaking. How is this done ? Well, Sun Microsystems ( the creators of Java) releases different Java Runtime software for different platforms ( Operating System + Microprocesser). The Java Runtime just intereprets the compiled intermediate code for the Java Virtual Machine and runs it. You just have to download the appropriate Java Runtime for your combination of Operating System and hardware.

Are any similarities between RapidQ with Java ?

Well, both are available for Windows and Linux. While the compiled code is protable in the case of Java, in the case of RapidQ only the source code is portable. Both create intermediate code which is then interpreted while running. In the case of Java, a separate software called the Java Runtime interprets the compiled code whereas in the case of RapidQ the interpreter that is bound to the intermediate code interprets it.

So much regarding a comparison of RapidQ with other compilers.

Bye!







No comments: