2.5 Programming Languages Flashcards
GLHF <3 (24 cards)
What is machine code?
1) Binary representation of instructions in a format that the CPU can decode and execute
2) Have an operation code (opcode) instruction and address or data to use (operand)
How are low-level languages written and translated?
1) Written in assembly language
2) Translated by an assembler into machine code
How are high-level languages written and translated?
1) Source code is written in languages such as Python, C++, Java, and Visual basic
2) Translated by a compiler or interpreter into machine code
What are low-level languages used for?
Used for embedded systems and device drivers where instructing the hardware directly is necessary.
Why are high-level languages used?
Makes the writing of computer programs easier by using commands that are like English
What are disadvantages of low-level langauges?
1) One instructions is translated into one machine code instruction
2) This code works on one type of processor only
3) Code is harder to write and understand
What are advantages of low-level languages?
1) Memory-efficient
2) Code is fast to execute
3) The programmer works with memory directly
What are advantages of high-level languages?
1) One source code instruction translates to many machine code instructions
2) Code will run on different types of processors
3) The programmer has lots of data structures to use
4) Code is quicker and easier to understand and write
What are disadvantages of high-level languages?
1) Less memory-efficient
2) Code can be slower to execute if it is not optimised
What is the purpose of translators?
Code written in both assembly and high-level source code is converted into binary code for execution. This is the purpose of a translator.
What does a compiler do?
Translates source code from high-level languages into object code and then into machine code ready to be processed by the CPU. The whole program is translated into machine code before it is run.
What does a compiler create?
A compiler will create a single, executable file that can be run without the original source code
What are the advantages of a compiler?
1) No need for translation software at run-time
2) Speed of execution is faster
3) Code is usually optimised
4) Original source code is kept secret
What are the disadvantages of a compiler?
1) Source code is easier to write in a high-level language but the program won’t run with syntax errors, making it more difficult to write the code
2) Code must be recompiled when the code is changed
3) Designed for a specific type of processor
What does an interpreter do?
Translates source code from high-level languages into machine code ready to be processed by the CPU. The program is translated line by line as the program is running.
What are the advantages of using interpreters?
1) Easy to write source code because the program will always run, stopping when it finds a syntax error
2) Code does not need to be recompiled when code is changed and it is easy to try out commands when the program has paused after finding an error
3) This makes interpreted languages very easy for beginner programmers to learn to write code
What are the disadvantages of using interpreters?
1) Translation software is needed at run-time
2) Speed of execution is slower
3) Code is not optimised
4) Source code is needed
What are the four functions Integrated Development Environments (IDEs) provide?
1) Debugging tools for finding logic errors
2) Help with preventing and identifying syntax errors
3) Providing a run-time environment
4) Usability functions
How do IDEs provide debugging tools for finding logic errors?
1) Breakpoints - stopping a program at a line of code during execution
2) Stepping through lines of code one at a time to check which lines are executing
3) Tracing through a program to output the values of variables
How do IDEs help with preventing and identifying syntax errors?
1) Illustrating keyword syntax and auto-completing command entry
2) Error highlighting
3) The compiler produces an output of the error message to help identify it
How do IDEs provide a run-time environment?
1) Output (run-time) window
2) Simulating different devices the program should use
How do IDEs provide usability functions?
1) Navigation, showing/hiding sections of code
2) Formatting source code
3) Find and replace
4) Comment or indent regions
What is the path of low-level languages to machine code?
Low-level language -> assembler -> machine code (binary)
What is the path of high-level languages to machine code?
High-level language -> compiler (translator) -> object code -> machine code (binary)
OR
High-level language -> interpreter (translator) -> machine code (binary)