Types Of Programming Language Flashcards
Programming paradigm
Different approaches to using a programming language to solve a problem
(To describe an example of a way of doing things)
Turing complete language
Can solve all the problems that a computer is able to solve
What is the need for different programming paradigms
We need different programming paradigms because some problems are better suited to being solved using a certain paradigm
Machine code
Least abstract
Closest to what actually happens on a computer
These translate into matching electrical signals
Programs directly into 1’s and 0’s
Assembly language
Uses short code words (mnemonics)
Each mnemonic matches a specific sequence of 1’s and 0’s
Written in assembly language and translated by a specific assembler
One to one relationship
High level languages
The first languages that could go further than machine code and assembly language were developed in the early 1950s
These languages had a one to one relationship as each instruction could translate to many lines of machine code
Imperative languages
Use statements that change a programs state in the form of sequence, selection, iteration. Consists of commands for a computer to perform and focus on describing how a program operates
Declarative languages
Focus on what the program SHOULD accomplish
Sublevel of high level languages
Declarative
Imperative
Types of imperative
Object oriented
Procedural
Type of declarative
Logic
Functional
Object oriented
Modern extension of the imperative programming approach that focuses more on a modular approach to programming
Procedural
Type of imperative programming paradigm where a program is built from one or more subroutines
Advantages of machine code and assembly language
Assembly language has the same efficiency of execution as machine code due to its one to one nature
It can produce very precise, locally optimised and efficient code
It provides direct access to system level features without having to go through a software interface- this improves the speed of the program
In complete control of your code
Disadvantages of machine code and assembly language
It is machine dependant and code is very hard- if not impossible - to port
programmers who can write efficient assembly code are rare- which is one of the reasons why high level languages were produced in the first place
Even in the hands of a talented programmer code can be tedious to write and very prone to bugs
The code can be difficult to understand therefore it can also be hard to modify and maintain
Features of procedural programming paradigms
Sequence, selection, iteration
procedural programming paradigms data
Stored in local and global variables and accessible to other parts of the program using parameter passing
procedural programming paradigms structure
Procedures and function
procedural programming paradigms logic
Expressed in a series of procedure calls
Features of object oriented paradigms
Sequence, selection, iteration plus inheritance, objects, classes and encapsulation
object oriented paradigms data
Stored in attributes and concealed from other parts of the program via encapsulation
object oriented paradigms structure
Classes, methods and instances
object oriented paradigms logic
Based on models and behaviours
Procedural language programming features
Variables
Constants
Selection
Iteration
Sequence
Subroutines
String handling
File handling
Operators
Arrays
How is code developed (procedural)
Developed in a modular way. Blocks of code identify set tasks that need to be completed. Use procedures and functions to achieve this
What do procedural languages focus on
Focus on telling a computer exactly what to do by way of step by step instructions
Types of addressing memory methods
Immediate
Direct
Indirect
Indexed
Immediate addressing
Immediate operand, the value in the address part of the instruction is actually the value to be used, so the memory does not need to be searched to find the required value
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
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
Indirect addressing (usefulness)
This mode of addressing memory is incredibly useful, as it means larger address ranges can be used to reference data and instructions
Indexed addressing
More efficient to use an index register (IR)
The IR is set to 0 so first value is taken from 0 + memory address
The IR is incremented and the same instruction is used again
Why an array needs to be stored in contiguous memory locations. Store address for element 0 of the array in the index register then increment
Constructor method
A special method within the class that runs when an object of the class type is created
When the object is created the constructor method takes the values of the parameters passed into the class object and sets its local attributes to their initial values
Three main sections of classes
The name of the class
It’s attributes- variables
Its methods- subroutines
Class
A class is a blueprint used to set or define what attributes and methods an object of a certain type should have. A class is not an object. (Every object from that class looks the same)
Object
An instance of a class which contains both properties and behaviours within it
Instantiation
The process of creating an object from a class template
Inheritance
Allows a class to share the properties (attributes) and behaviours (methods) of another class
Overriding
Occurs automatically when you call a method from an object that shares the same name as a method further up the class tree.
The overriding method takes place and replaces the method from the superclass
super<dot>prefix.</dot>
When using super<dot>prefix. overriding is ignored and the method from the original superclass is used instead</dot>
Encapsulation
The bundling of data with the methods that operate on and restrict direct access to it
Used to hide the values or internal state of an object, preventing direct access by unauthorised parties
Encapsulated attributes of an object should only be accessible or changeable via the methods provided by the object
Helps keep the data related to an object safe- programmer stays in control
Accessing private attributes (encapsulation)
Other instantiated objects are prevented from directly accessing or altering the objects private attributes (like local variables) without going through its methods first
Any attempt to directly access an objects private attributes will result in an error
You must supply methods if you want an objects internal attributes to be read or altered
An objects methods are usually set to public, not private
As the methods are part of the same objects as its private attributes it will be able to access them
Polymorphism
Something that occurs in several different forms
Two types of polymorphism
Static
Dynamic
Static polymorphism
Allows you to implement multiple methods of the same name, but with different parameters, within the same class- method overriding
Parameter sets must differ in one of three ways (static polymorphism)
They need to have a different number of parameters
The types of parameters need to be different
Need to expect the parameters in a different order
Inheritance hierarchy
Subclass is able to override method of its superclass
It is a form of polymorphism and it provides different functionality depending on whether they are implemented by the superclass or the subclass
When should you use object oriented techniques
OOP works best in situations where you can encapsulate and model entities as objects. This allows you to define objects as classes and better understand and how they relate to and interact with each other
How does OOP relate to GUI
Good way to develop Graphical User Interface
Developed in parallel with the first GUI
Operand
Contains value
Opcode
Basic machine operation