Compilers take your source code, that is the code that you have written, and translate it into machine language so that the computer can understand it. It checks to make sure everything is grammatically correct first. Should it find something wrong it will spit out syntax errors and stop compiling. Should everything check out, it will create a separate file with the machine code translation and run it. Compiling large amounts of code will take some time, which is why interpreters are often used during the creation process, however, compiled code usually runs much faster than interpreted code.
So the main advantages of compilers is that they:
- produce programs which will run very quickly.
- can spot syntax errors whilst the program is being compiled (however this does not necessarily mean the program is error free if it completely compiles, just that there are no grammatical errors)
So the main advantages of interpreters is that they:
- have no lengthy compile time, i.e. you do not have to wait between writing a program and running it. As soon as you have written the program you may run it, which is great for checking larger programs.
- tend to be more portable, that is an interpreter will run on a greater variety of machines, because each machine can have it's own interpreter for that language.
Finding interpreters and compilers for these languages is typically a very simple process. A simple Google search will turn up many interpreters and compilers that you could choose from. Often these are largely similar with a few key or minor differences between them in how they run and what they output. For example: a Google search of "interpreter and compiler for C" on the first page gives you 6 different possibilities for a download, mostly free software. The other 4 are pages with explanations of interpreters and compilers. It is crucial that you read the page you find it on and find out what exactly that particular interpreter or compiler will do. For many languages the developers will have a website with their compiler program for the language on it, such as Sun Microsystems with their Java language or Microsoft with their C# language.
No comments:
Post a Comment