What is the difference between an interpreter, assembler, and compiler?
Submitted By: Craig Steiner FAQ Last Modified: 07/10/06
- This isn't specifically an 8052 questions as the question (and answer) applies to any architecture. These three terms refer to three different ways of getting your program concept to run a given processor, each with varying levels of ease in programming and efficiency in execution.
An interpreted program is one in which the program must be analyzed each time the program is run to determine what actions the processor should execute. Since the program is essentially "compiled on the fly," program execution is generally slow in comparsion to other options. Code size is often larger, too, since not only is your program held in code memory but also the "kernel" which actually interprets and executes your program. Interpreted languages are usually only useful for learning purposes and are seldom used in commercial projects. An example of an interpreted option with the 8052 is 8052-BASIC.
An assembler allows you to write your program in assembly language which is one step away from pure machine language. The assembler actually translates your assembly program into machine language. A well-written assembly language program will provide the most speed and smallest code size, but writing a program in assembly language is generally considered to be more advanced and more difficult than writing a similar program in an interpreted or compiled language. Most 8052 programmers work in assembly language (about 52% according to a recent 8052.com survey). Using assembly language also gives you complete control over what the processor is doing.
A compiler is used when the programmer wishes to write his code in a high-level language, such as C, Pascal, or sometimes Basic. In the 8052 community, C is the most popular compiled language. A compiler translates the source code written in the high-level language to machine language; thus the resulting output is the same as the output of an assembler--pure executable machine code. Most modern compilers are relatively efficient and produce relatively tight code. However, an equivalent C program will almost require more code size than the same program in assembly language--unless the assembly language program was very poorly written.
The advantage to using a high-level language is that more programmers are familiar with C, Pascal, and Basic than are familiar with 8052 assembly language. High-level language programs are also, arguably, easier to read and understand than the same program in assembly language and, thus, are often easier to maintain--especially if the program will have to be maintained by someone other than the original programmer(s).
Add Information to this FAQ: If you have additional information or alternative solutions to this question, you may add to this FAQ by clicking here.