Programming languages Flashcards

1
Q

Describe what is meant by a ‘low-level language’ using examples.

A

Machine code and assembly language are low-level languages that work directly with a computer’s hardware

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is machine code?

A
  • Written in binary, made up of thousands of 1s and 0s
  • This makes it very difficult for programmers to write and debug
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is assembly language?

A
  • Only a bit easier to work with
  • Uses mnemonics to represent instructions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give some advantages and disadvantages of using low-level languages.

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe what is meant by a ‘high-level language’ using examples.

A

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’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe some features of high-level languages.

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give some advantages and disadvantages of using high-level languages.

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(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)

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(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)

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the condition for programs to be executed by the CPU?

A

Programs have to be translated into machine code before they can be executed by the CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

(Exam-style question)

Explain one reason why program code developed using a high-level language must be translated. (2)

A

Instructions must be translated into machine code because that is the only language the CPU can execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give three examples of translators.

A
  • Compiler
  • Interpreter
  • Assembler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

State the purpose of a compiler.

A

To translate a high-level language’s source code into machine code (object code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

State the purpose of an interpreter.

A

To translate high-level code line by line into machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

State the purpose of an assembler.

A

To translate assembly language into machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Give some advantages of using a compiler to translate a programming language.

A
  • Translates all program code into machine code at same time
  • Program only has to be translated once - allows for faster execution of program
  • Protects software from competitors as source code is not available to them
17
Q

Give some disadvantages of using a compiler to translate a programming language.

A
  • Reports list of errors after having compiled whole program if it encounters any, making debugging harder
  • You cannot change the program without going back to, editing and recompiling the original source code
  • Compiled programs can only be ran on specific systems
18
Q

Give some advantages of using an interpreter to translate a programming language.

A
  • Stops translating program when an error is found and reports it - lets programmer know where it occurred, making debugging easier
  • Program code can run on any system that has the interpreter
  • Program can be easily edited as it always exists as source code
19
Q

Give some disadvantages of using an interpreter to translate a programming language.

A
  • Each line of code has to be translated every time program is executed, therefore it is slower to run