1.2.4 types of programming languages Flashcards
(32 cards)
what are programming paradigms
Different approaches to using a programming language to solve problems.
which two broad categories are programming paradigms split into
-imperative
-declarative
Imperative programming paradigms
uses code that clearly specifies the actions to be
performed
Declarative programming paradigms
focuses on stating the desired result rather than the exact series of instructions that need to be performed to get to the result. . It is the role of the programming language to determine how best to obtain the result and the details about how it is obtained are abstracted from the user.
Advantages of procedural programming
-can be applied to a wide range of problems
- relatively easy to write and interpret
procedural programming
This is a type of imperative programming which uses a sequence of
instructions which may be contained within procedures. These instructions are carried out in a step-by-step manner.
state a use of declarative programming
-Artificial intelligence
-expert systems/knowledge based systems
identify the 4 main structures used in structural programming
-sequence
-selection
-iteration
-recursion
Sequence
Code is executed line-by-line, from top to bottom.
Selection
A certain block of code is run if a specific condition is met, using IF
statements.
Iteration
A block of code is executed a certain number of times or while a condition is met. Iteration uses FOR, WHILE or REPEAT UNTIL loops.
Recursion
Functions are expressed in terms of themselves. Functions are executed, calling themselves, until a certain condition known as a base case (which does not call the function) is met.
what is procedural programming suited for
suited to problems that can easily be expressed as a series of instructions
how does assembly language differ from machine code
Assembly language uses mnemonics rather than binary. One line in assembly language is equal to one line in machine code
mnemonics
state the function of opcode and operand
the opcode specifies the instruction to be preformed and addressing mode. The operand holds a value which is related to the data on which the instruction is to be preformed
state 4 addressing modes
-immediate addressing
-direct addressing
-indirect addressing
-indexed addressing
Immediate Addressing
The operand is the actual value upon which the instruction is to be performed, represented in binary. So the memory does not need to be searched to find the required value
Direct Addressing
The operand gives the address which holds the value upon which the instruction is to be performed. Direct addressing is used in LMC.
Indirect Addressing
The operand gives the address of a memory location which holds another address, where the data is located.
Indexed Addressing
An index register is used, which stores a certain value. The address of the operand is determined by adding the operand to the index register. This is necessary to add an offset in order to access data stored contiguously in memory such as in arrays
Advantages of oop
-oop allows for high level of usability which makes it useful for projects with many components
-classes can be used across multiple projects
-There is a high level of abstraction and it is not necessary for programmers to know details about how code is implemented.
-The modular structure used in OOP makes it easy to maintain and update.
-Encapsulation is a key reason for choosing OOP as it makes the code more reliable by protecting attributes from being directly accessed.
Polymorphism
Ability for methods of the same name to be used in inherited classes with different behaviours exhibited
Inheritance
Inheritance is when a class takes on the methods and attributes of a parent class. The inheriting class may override some of these methods/attributes and may have additional extra methods and attributes of its own