Translators Flashcards
What are high level languages?
- structured english
- languages like python and C++
- source code easy for humans to read
- computers need to translate it to machine code to read it and run it.
What are low level languages?
- tricky for humans to read and write
- easier for a computer to run
- consist of machine code and assembly language
What are advantages of high level languages?
- the same code will work for many different machines and processors.
- programmer can easily store data in lots of different structures (e.g. lists and arrays) without knowing about memory structure.
- code is easy to read, understand and modify.
What are disadvantages of high level languages?
- must be translated into machine code before a computer is able to understand it.
- you don’t have much control over what the CPU actually does so programs will be less memory efficient and slower.
How many instructions of high level code represents machine code?
One instruction of high level code represents many instructions of machine code.
How many instructions of assembly code represents machine code?
One instruction of assembly code represents one instruction of machine code.
What are the advantages of low level languages?
- commands in machine code can be executed directly without the need for a translator.
- you control exactly what the CPU does and how it uses memory so programs will be more memory efficient and faster.
What are the disadvantages of low level languages?
- usually written for one type of machine or processor and won’t work on any others
- programmer needs to know about the internal structure of the CPU and how it manages the memory.
- Code is very difficult to read, understand and modify.
What are the three types of translator?
assemblers, compilers and interpreters
What are assemblers used for?
To turn assembly code into machine code. There are many different assembly languages (to support different CPU types) and each one needs its own unique assembler.
What are compilers and interpreters used for?
To turn high level languages into machine code.
How does a compiler work?
- translates all of the source code at the same time and creates one executable file.
- only needed once to create the executable file.
- returns a list of errors for the entire program once compiling is complete.
- once compiled the program runs quickly but compiling can take a long time.
How does a interpreter work?
- translates and runs the program one instruction at a time, but doesn’t create an executable file.
- needed every time you want to run the program
- the interpreter will return the first error it finds and them stop - this is used for debugging.
- programs will run more slowly because the code is being translated as the program is running.
What translator is used?
Depends on the programming language and IDE you’re using.
What is used if the program is stored over multiple source code files?
A linker is used to join all the separate compiled codes into one executable program.