1.2.4 Flashcards
Types of programming language (33 cards)
Key features of procedural languages
Sequence
Selection (a.k.a. Branching)
Iteration
Recursion.
Positives and negatives of procedural languages
- Simple to implement.
- Applicable to many problems.
- Is not suited to every problem.
- Uses traditional data types and structures.
What are procedural languages good for?
Writing code with lots of algorithms.
Anything where you want fine control and high performance but want more portability than assembly language.
What are procedural languages bad for?
Brevity (other paradigms provide more concise alternatives).
Object oriented language features and examples
Encapsulation, Instantiation, Inheritance, Polymorphism.
Example languages: Java, C++, C#, Python, JavaScript
What are object oriented languages good for?
Abstraction when dealing with real world objects.
Modularity.
What are object oriented languages bad for?
Efficient code for limited resource environments
transparent (easy to trace) code
concurrent programming
Low level languages key features and examples
Opcodes (Mnemonics), Operands, Registers, Memory Modes
ARM Assembly, x86 Assembly, Little Man Computer
What are low level languages good for?
Device drivers
OS development (particularly embedded systems)
ultra high performance code
What are low level languages bad for?
Portability
abstraction
rapid development
Features an examples of functional languages
First Class, Higher Order and Pure Functions. Immutability
JavaScript, LISP and countless other multi-paradigm languages Haskell (Pure functional language)
What are functional languages good for?
Robust, predictable and reliable code.
Efficient and highly optimisable code.
Concurrency safe processing.
What are functional languages bad for?
Beginners
Declarative languages features and examples
Queries, C.R.U.D., Facts and Rules, Relationships
SQL, Prolog
What are declarative languages good for?
Databases, Expert systems, Artificial Intelligence
What are declarative languages bad for?
Control over what the computer is actually doing!
What are the modes of memory addressing?
Immediate Addressing (literal)
Direct Addressing (reference to a cell in memory)
Indirect Addressing (reference to a cell in memory pointing to another cell)
Indexed Addressing (reference plus offset)
Immediate Addressing (Literal)
Operand is an actual value, i.e. a literal number, rather than a memory location. Literal.
Needs no access to RAM - no fetch is required.
Range of values is limited by the size of the operand (eg if there are 4 bits for the operand, the literal value can only be 0 - 15)
Direct Addressing (Pointer)
Operand is a memory location, like Little Man Computer.
This mode is good when programmer a wants global variable.
Address is constant throughout the program executive since it’s part of the assembly program instruction
Indirect Addressing (Pointer to Pointer)
Operand is a memory location pointing to another memory location to be used.
Multiple fetches are required.
This mode allows access to more memory. Why? An 8 bit instruction might have 4 bits for the opcode, 4 bits for the operand (max 16 memory locations can be referenced). The pointed to memory location can use all 8 bits to reference 128 memory locations available.
Indexed Addressing (Pointer plus offset)
Operand is a memory location plus an offset stored in a special Index Register.
This mode is ideal to store and access values stored sequentially for example in arrays since arrays are stored in contiguous memory locations. The pointer points to the memory location of the first element in the array. By incrementing or decrementing the offset, different elements of the array can be indexed.
Class
A template for an object. Defines the behaviour and state of the object.
State
Defined by attributes giving the object’s properties.
Behaviour
Defined by the methods. Describes the action an object can perform.