2.2 (APPLICATIONS) Flashcards

1
Q

What is a translator?

A

Translators convert source code from a high-level language to a low-level language
There are three main types of translators:
Interpreters
Compilers
Assemblers

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

What is an interpreter?

A

Interpret source code line-by-line and executes it on the fly
Easier to debug, allows incremental testing, and is generally faster to start execution
Slower execution time overall and requires the interpreter to be present during the execution
If an error is found there is no need to recompile the whole code

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

What is a compiler

A

Translates the entire source code into machine code at once and then executes it
Faster execution time, no need for the compiler during execution
Longer initial compilation time and can be more challenging to debug
can be run many times without needing to be recompiled

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

What is an assembler?

A

Assemblers translate assembly language into machine code
Unlike interpreters and compilers that work with high-level languages, assemblers deal with low-level languages

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

Give the order of abstraction in programing languages? (High to low, 5)

A

High level interpreted-Javascript, python
High level compiled- C, C++
Assembly- assembly language
Machine- Hex representaion of binary code
Binary- Binary

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

compare the development paradigms f compilers and interpreters

A

Interpreted languages allow determining variable types at runtime, which makes development faster
e.g. ‘'’var x = 5’’‘(Interpreter will calculate x to be a number at runtime)

Compiled languages enforce stricter type-checking at compile time, which requires additional work across the project
e.g. ‘'’String var name = ‘Michael’;’’’ (Compiler will demand that name has a datatype before compiling)

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

State the stages of compilation (4)

A

Lexical analysis
Syntax analysis
Code generation
Optimisation

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

What happens during lexical analysis?

A

Lexical ‘tokens’ are identified
Tokens represent small meaningful units in the languge
e.g. Keywords: ‘var’, ‘function’, ‘while’
Identifiers: variable names,function names
Operators : ‘+’, ‘-‘
Seperators: ‘:’, ‘;’
Unnescesary elements like comments and whitespace are removed
A token table is produced

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

What happens during syntax analysis?

A

Makes sure the tokens adhere to the syntax rules of the language
If the code passes the syntax analysis, the compiler can create an Abstract Syntax
Tree (AST)
An AST is a graph-based representation of the code being compiled
An AST is an efficient way to represent the code for the next step

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

What happens during code generation?

A

Takes the AST to generate object code that can be executed

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

What happens during optimisation?

A

This step modifies the code to make it more efficient without changing its functionality
This is important to attempt because it reduces the memory required to run the code, which leads to faster execution
A common optimisation action is removing duplicate code
If an ‘add’ function is written twice in the source code, a sophisticated compiler will notice this and include it only once in the object code

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

What is a library?

A

A code library is a collection of pre-written code, classes, procedures,scripts, configurations, and more. They are packaged together to allow developers to perform common tasks without having to write code from scratch.

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

What are the benefits of libraries?

A

Efficiency: Saves time and effort, as you don’t need to write everything from scratch
Reliability: Often tested and optimized, reducing the chance of errors
Reusability: The same library can be used in different parts of the project or in different projects
Community Support: Popular libraries often have strong community support and documentation

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

What are the drawbacks of libraries?

A

Dependency Issues: Relying on a third-party library can lead to problems if the
library is discontinued or not maintained
Compatibility: There might be compatibility issues with different versions of the
library or the system you are working on
Overhead: Using a large library for a small task can add unnecessary complexity and
size to the application

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

What does a linker do?

A

These combine different code files and libraries into a single executable.
They resolve references between files, ensuring everything points where it should

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

What does a loader do?

A

These are system tools that load executable files into memory so they can be run by the operating system