2.4 Types Of Programming Language Flashcards
What are 2 types of programming paradigms and what is the difference?
Declarative languages e.g. SQL contain code that describes the goal/operation that needs to be achieved but not how to achieve it.
Imperative languages use code that clearly specifies the actions to be performed in order to solve a problem.
What are the 2 main imperative types of programming language?
procedural
object oriented
What is a procedural language?
A language that solves a problem by carrying out a series of instructions step by step. e.g. python
What is an object oriented language?
A language that is based on objects of different classes that have methods and attributes. e.g. JavaScript
When is OOP better suited in general?
Problems where we can represent real life entities with objects or higher scale complex software.
What are the 4 programming constructs and what do they mean?
sequence - line by line execution of code
selection - block of code ran based on a condition
iteration - block of code ran repetitively based on a condition or for a set number of times (count or condition controlled)
recursion - when a function calls itself until a certain condition is met which returns a different value
What is the opcode?
The type of instruction to be performed.
What is the operand?
The data or address upon which the instruction is performed.
What are 4 memory addressing modes?
immediate addressing
direct addressing
indirect addressing
indexed addressing
What is immediate addressing?
When the operand is the actual value that the opcode is performed on.
What is direct addressing and why is it used?
When the operand is the address of the location in memory that contains the data upon which the instruction is performed.
This is used to represent higher numbers as memory has access to more bits than the operand.
What is indirect addressing and why is it used?
When the operand is the address in memory that stores another memory address that is the location of the data upon which the instruction is performed.
This is used to access more memory addresses as memory can represent more bits than the operand.
What is indexed addressing and when is it used?
The operand is added to the value in the index register to produce the memory address of the location of the data that the instruction is performed on.
This is used for arrays as the index register stores an offset that represents the start of the array so that the data can be stored contiguously.
What is a class?
A template for defining methods and attributes, used to create objects.
What is an object?
A single instance of a class that can have its own values for the class’ attributes.