1.2.4 Types of Programming Language Flashcards
what is a paradigm?
to describe an example of a way of doing things
what does Turing complete mean?
a computer language that can solve all the problems a computer is able to solve
why do we need different paradigms?
some problems are better suited to being solved using a certain paradigm
what are the characteristics of machine code?
- least abstract
- closest to what actually happens in computer
- programs in 1s and 0s
- translated into electrical signals
what are the characteristics of assembly language?
- uses mnemonics
- each mnemonics matches a specific binary code
- one to one relationship
- translated by an assembler
what are the characteristics of high-level languages?
- can go further than machine and assembly
- one-to-many relationship - each instruction is equivalent to many lines of machine code
- so much more complex so are high level
what are the two categories of high level languages?
- imperative
- declarative
what are the characteristics of imperative languages?
- uses statements which change a program’s state (eg. sequence, selection, iteration)
- consists of commands for a computer to complete
- focus on how a program operates
what are the characteristics of a declarative language?
- focuses on what the program should accomplish
what are the two paradigms under imperative languages?
- object oriented
- procedural
what is the characteristic of procedural programming?
program is builds from one or more subroutines
what is the characteristic of object oriented programming?
modular approach to programming
what are the advantages of machine and assembly?
- assembly has the same efficiency as machine as it is a one to one relationship
- it can produce very precise, locally optimised and efficient code
- it provides direct access to system level features - improves speed
- complete control of code
what are the disadvantages of machine and assembly?
- machine dependant and very hard to port
- rare to find efficient assembly coders
- very tedious and prone to bugs
- difficult to understand
what features do procedural languages have?
sequence, selection, iteration
what features do oop have?
sequence, selection, iteration
+ inheritance, objects, classes and encapsulation
how is data stored in procedural languages?
local or global variables
accessible through parameter passing
how is data stored in oop?
attributes and concealed from other parts of program through encapsulation
what is the program structure for procedural languages compared to oop?
- procedures and functions
- classes, methods and instances
what is the program logic for procedural languages compared to oop?
- expressed in a series of procedure calls
- based on models and behaviours
how is the code laid out in procedural languages?
- series of statements such as sequence, selection and iteration
- developed in a modular way with subroutines
how is assembly code converted to machine code?
translated by an assembler
what are the mnemonics for add, subtract store and load?
ADD
SUB
STA
LDA
what are the mnemonics for branching instructions?
BRA
BRZ
BRP
what are the mnemonics for input, output, end program and data location?
INP
OUT
HLT
DAT
what does the instruction register hold?
the first digit of the instruction read from memory = opcode
what does the address register hold?
2nd and 3rd digits of the instruction = operand
what are labels in LMC?
any characters which are not mnemonics
refer to addresses in RAM
if label is before DAT, it represents the address
if the label is after DAT, it is calling on the label
what is immediate addressing?
the value in the address part of the instruction is actually the value to be used, so memory does not need to be searched to find the required value
what is direct addressing?
the value in the address part of the instruction is a reference to the address in memory where the required value is located
what is indirect addressing?
the value in the address part of the instruction is a reference to a memory location that contains the address in memory where the required value is located
why is indirect addressing used?
it means larger address ranges can be used to reference data and instructions
what is indexed addressing?
uses an index register (IR)
takes the operand value and adds IR value then goes to this address in memory.
IR value increment to get the next memory address directly after the previous one
what is the structure of a class?
name
attributes (like variables)
methods (code to access or change attributes)
what is a class?
a blueprint (template) used to set or define what attributes and methods an object of a certain type should have
why are classes good?
it becomes easy to reuse the class and create hundreds of objects of that class
what is instantition?
the process of creating an object from a class template
how do you instantiate a new object of a class?
use the keyword NEW
what is a constructor method?
a special method within the class that runs when an object of that class type is created
what does the constructor method do?
takes the parameters passed into the object and sets its local attributes to their initial values
what is inheritance?
when a subclass is defined which uses/calls on the attributes and methods of another class and then adds additional attributes and methods which are required for this subclass
what is overriding?
using a method of the same name in a subclass that contains more specific code relevant to that class
- occurs automatically when there are 2 methods of the same name at different places of the class tree
how can overriding be prevented?
use super<dot> (eg super. )</dot>
how is inheritance done in code?
declare class and say which class it inherits from:
class <class> inherits <superclass></superclass></class>
what is encapsulation?
the bundling of data with the methods that operate on and restrict direct access to it
how are encapsulated attributes accessible or changable?
only via the methods provided by the object
which attributes are encapsulated?
private attributes
what is polymorphism?
something that occurs in several forms
giving an action one name that is shared up and down an object hierarchy, with each object in the hierarchy implementing the action in a way appropriate to itself
what are the types of polymorphism?
static
dynamic
what is static polymorphism?
allows you to implement multiple methods of the same name - but with different parameters - within the same class
= method overloading
what are the conditions for static polymorphism?
- need to have a different number of parameters
OR - the types of parameters needs to be different
OR - they need to expect the parameters in a different order
why is inheritance with methods of the same name in different classes polymorphism?
the two methods share the same name but provide different functionality depending on whether they are implemented by the superclass or subclass