Levels of Programming Languages
Levels of Programming Languages
• What is a translator?
• A translator is a program that translates program source
code into machine code so that it can executed directly by a processor
• Low-level languages such as assembly code are translated using
an assembler
• High-level languages such as Python are translated using
a compiler or interpreter
• What is a compiler?
• A compiler translates high-level languages into machine code all in one go
• Compilers are generally used when a program is finished and has been
checked for syntax errors
• Compiled code can be distributed (creates an executable) and
run without the need for translation software
• If compiled code contains any errors, after fixing, it will need re-compiling
What is an interpreter?
• (b) Either a compiler or an interpreter can translate the code. Describe two differences between how a compiler
and an interpreter would translate the code.[2]
• How to answer this question
• (a) what time of language does a computer understand?
• (b) the keyword is 'how'
• Answer
• (a)
• To convert it to binary/machine code
• The processor can only understand machine code
• (b)
• Compiler translates all the code in one go...
• ...whereas an interpreter translates one line at a time
• Compiler creates an executable...
• ...whereas an interpreter does not/executes one line at a time
• Compiler reports an error at the end...
• ...whereas an interpreter stops when it finds an error
Tools & Facilities in IDEs
• What is an IDE?
• An Integrated Development Environment (IDE)
is software designed to make writing high-level
languages more efficient
• IDEs include tools and facilities to make
the process of creating/maintaining code
easier, such as:
– Editor
– Error diagnostics
– Run-time environment
– Translators
• Editor
• An editor gives users an environment to write, edit
and maintain high-level code
• Editors can provide:
– Basic code formatting tools - changing the font, size of the
font and making text bold etc
– Prettyprint - using colour to make it easier to identify
keywords, for example 'print', 'input' and 'if' in Python
– Code editing - auto-completion and auto-correction of
code, bracket matching and syntax checks
– Commenting code - allows sections of code to be
commented out easily to stop it from being run or as
comments on what the program is doing
Error-diagnostics