Uploaded by ablakulovoybek

Translators & Compilers

advertisement
Translators & Compilers
Language Translators
• It is a software which converts or translates a programming language
• to machine code.
• All programs and websites are written using programming languages
and script languages.
• Revisezone is built using 3 Languages
• HTML,CSS & JS - however html and css are not programming
languages
• There are two types of translators - interpreter and compilers
• Programming languages are broken down to two types:
High level Language
• Usually, the source code of a program is written by the programmer in
high level language.
• This must be converted to a form which can be understood by the
computer.
Low level language
• These are programming languages which are closely related to
machine code.
• Machine code is another word for binary code.
• Compilers and Interpreters only translate high level languages and not
assembly language.
Compilers
• The translator first translates the source code into an intermediate
code and the code is compiled as a whole.
• If there are errors present at the end of the process it will display an
error diagnostics, but it will not produce any final machine or compile
code.
• If no errors are detected the intermediate code is then converted to a
machine executable code.
• This compiled code is in binary and so it runs directly on the
processor.
Advantages
• An executable code is produced which can be distributed. This is also
more secure as the users will not receive the source code.
• Doesn't require the translator software to run the compiled code
• Executes very fast and directly on the processor
Disadvantages
• Compiled programs can have viruses
• The compilation process is quite long and resourceful and also
provides a compiled code after all the errors have been corrected
• Higher chance of system crashing
Interpreter
• This type of translator executes the code line by line and not the
whole code at once
• It produces an object or machine code for each line and executes it.
• If an error is identified the execution stops and thus alerts the user to
correct the error
Advantages
• Best for debugging and testing purposes as it produces an alert as
soon as the error is found
• The whole code doesn't have to be written as the code is translated
line by line
Disadvantage
• The execution of the process is very slow
• The source code is seen by the user so it less secure
• The translator is used every time the program is executed
• The main use of interpreters is for building a program
Download