2.5 Programming languages and IDEs Flashcards
What is a high level language?
The source code is easy for humans to write but computers need to translate it before they can read and run it.
What are advantages of a high level language?
-One instruction of high level code represents many instructions of machine code.
-The same code will work for many different machines and processors.
-The programmer can easily store data in lots of different structures (lists and arrays) without knowing about the memory structure.
-Code is easy to read, understand + modify.
What are disadvantages of a high-level language?
-Must be translated into machine code before a computer is able to execute instructions as computers can only understand instructions given to them in machine code.
-Don’t have much control over what the CPU actually does so programs will be less memory efficient and slower.
What are 2 types of translator used to translate high-level code into machine code?
-Compilers.
-Interpreters.
What is a compiler?
-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.
What is an interpreter?
-Translates and runs the source code 1 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 then stop, which is useful for debugging.
-Programs will run more slowly because the code is being translated as the program is running.
Which type of translator will be used when translating a high-level language into machine code?
Dependent on the programming language and IDE being used.
What is a linker?
Used to join all of the separate compiled codes into one executable program if the program is stored over multiple source code files.
How does an interpreter run the source code one instruction at a time?
They take each instruction in the code and call machine code subroutines within their own code to carry out that instruction.
What are advantages of a low-level language?
-Commands in machine code can be executed directly without the need for a translator as computers can understand machine code.
-You control exactly what the CPU does and how it uses memory so programs will be more memory efficient and faster.
What are disadvantages of a low-level language?
-One instruction of assembly code usually only represents one instruction of machine code.
-Usually written for one type of machine or processor and won’t work on any others.
-The programmer needs to know about the internal structure of the CPU and how it manages the memory.
-Code is very hard to read, understand + modify.