Programming languages Flashcards
Describe what is meant by a ‘low-level language’ using examples.
Machine code and assembly language are low-level languages that work directly with a computer’s hardware
What is machine code?
- Written in binary, made up of thousands of 1s and 0s
- This makes it very difficult for programmers to write and debug
What is assembly language?
- Only a bit easier to work with
- Uses mnemonics to represent instructions
Give some advantages and disadvantages of using low-level languages.
Advantages:
- Interact directly with the hardware, enabling memory to be used efficiently - allows for faster execution of a program
Disadvantages:
- Difficult and time-consuming to use
- Have few tools that help with debugging and maintenance
- They are machine-specific
Describe what is meant by a ‘high-level language’ using examples.
High-level languages, such as Java and Python, are programming languages closer to human languages than low-level languages
(use keywords like ‘print’, ‘if’ and ‘return’)
Describe some features of high-level languages.
- They are problem-oriented - enable programmers to focus on a program’s logic, rather than on how it will be implemented on a computer’s hardware
- Come with libraries of ready-made functions and editing tools to make it easier to write code
Give some advantages and disadvantages of using high-level languages.
Advantages:
- Programmer-friendly
- Have tools that help with debugging and maintenance
- They are machine-dependent (portable) - will run on computers with different types of CPU
Disadvantages:
- Generally less memory efficient
(Exam-style question)
A program written in a high-level language will run on computers with different types of CPU, whereas one written in a low-level language is machine-specific.
Explain this difference. (3)
- Programs written in a high-level language focus on the program logic and do not concern themselves with how it will be implemented on particular computer architecture
- Programs written in a low-level language use the instruction set of a specific CPU
(Exam-style question)
A program is needed to control an embedded system with very limited on-chip memory.
Explain one reason why a programmer may decide to write the program in a low-level language. (2)
- Using a low-level language ensures that the system’s memory is used efficiently
- This is because it enables the programmer to select the most appropriate instructions to use and to directly control the hardware to be used
What is the condition for programs to be executed by the CPU?
Programs have to be translated into machine code before they can be executed by the CPU
(Exam-style question)
Explain one reason why program code developed using a high-level language must be translated. (2)
Instructions must be translated into machine code because that is the only language the CPU can execute
Give three examples of translators.
- Compiler
- Interpreter
- Assembler
State the purpose of a compiler.
To translate a high-level language’s source code into machine code (object code)
State the purpose of an interpreter.
To translate high-level code line by line into machine code
State the purpose of an assembler.
To translate assembly language into machine code