1.2.4 Types of Programming Languages Flashcards
What are programming paradims?
- Different approaches to using a programming language to solve a problem .
What are the two broad catagories of programming paradims?
- Imperative
- Declarative
What is an imperative programming paradims?
- Use code that clearly specifies the actions to be performed .
What are the types of imperative programming paradigms?
- Procedural
- Object-oriented
What is a procedural programming paradigmn?
- Uses a sequence of
instructions which may be contained within procedures. - These instructions are carried out in a step-by-step manner .
What are the advantages of procedural programming paradigmn?
- Applied to a wide range of problems
- Easy to write and interpret
What is Object-Oriented programming (OOP) paradigmn?
- Built on entities called objects formed from classes which have
certain attributes and methods .
Advantages of Object Orriented programming ?
- Designs code that is resuable
- Easy to update and maintain
What is a declaritive programming paradigmn?
- Focuses on stating the desired
result rather than the exact series of instructions that need to be performed to get to the result. - To determine how best to obtain the
result - Details about how it is obtained are abstracted from the user .
- Common in expert systems and artificial intelligence
What are the types of declaritive programming paradigms?
- Functional
- Logic
What is functional programming?
- Uses the concept of reusing a set of functions.
- Programs are made up of lines of code consisting of function calls.
What is logic programming paradigms?
- Use code which defines a set of facts and rules based on the problem.
- Queries are used to find answers to problems.
What are the features of a procedural language?
- Sequencing
- Selection
- Iteration
- Recursion
What is assembely language?
- The next level up from machine code
and is part of a family of low level languages. - Converted to machine code using an assembler when it is executed.
Features of assembly language
- Uses mnemonics rather than binary,
which makes it easier to use than direct machine code. - Each mnemonic is represented by a numeric code .
- Commands that assembly language uses are processor-specific.
- This allows for direct interaction with
hardware so is useful in embedded systems. - Each instruction in assembly language is equivalent to almost one line of
machine code.
What is machine code made up of?
Operand and Opcode
What is opcode?
- The opcode specifies the instruction to be performed from the commands table
What is operand?
- The operand holds a value
which is related to the data on which the instruction is to be performed. - May hold the actual value on which the instruction is to be executed but more often, it holds an address related to where this data is stored.
What are adressing modes?
- Specifies how the operand should be interpreted
- Part of the opcode
- Allow for a much greater number of locations for data to be stored as
the size of the operand would otherwise constrain the number of addresses that could be accessed.
What are the four types of addressing modes?
- Immediate Addressing
- Direct addressing
- Indirect addressing
- Indexed addressing
What is immediate addressing?
- The operand is the actual value upon which the instruction is to be performed, represented in binary
What is 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.
What is Indirect Addressing?
- The operand gives the address of a register which holds another address, where the data is located .
What is 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 .
What are the features of Object Oriented Programming?
- Classes
- Objects
- Methods
- Attributes
- Inheritence
- Encapsulation
- Polymorphism
What are classes?
- A class is a template for an
object and defines the state and behaviour of an object.
What are objects?
- An object is a particular instance of a class.
What are methods?
- Dunctions associated with objects or classes
- Define the behaviour and actions that objects can perform
What are attributes?
- Give an objects its properties
What is inheritence?
- The subclass (derived class) will possess all of the methods and
attributes of the superclass (parent class) - Can have its own additional properties
- Allows programmers to effectively reuse certain components and properties while making some changes .
What is encapsulation?
- Atrributes cannot be directly accessed and edited by users
What is polymorphism?
- A property of OOP that means objects can behave differently depending
on their class .
What are the types of polymorphism
- Overriding
- Overloading
What is overriding polymorphism?
- Overriding is redefining a method within a subclass and altering the code so that it functions differently and produces a different output .
What is overloading polymorphism?
- Passing in different parameters into a method.
What are the advantages of OOP?
- High level of reusability thanks to inheritance and polymorphism.
- Encapsulation makes the code more reliable by prtecting attributes from being directly accessed
- OOP requires advances planning resulting in higher quality products
- Modular structure makes it easy to maintain and update
- High level of abstraction allowing for classes to be used a s black box once created
What is a getter?
- Special method used in OOP to retrieve the value of a given attribute
What is a setter?
- Special method used in OOP that sets the value of a particular attribute