Download: 1.2.4 Types of Programming Language
Programming Paradigms: This is a style of computing programming. It is a way of coding to solve a problem.
Different programming languages support tackling problems in different ways. There are four main programming paradigms, each supported by a number of different languages.
Procedural Programming: This is the most common paradigm of programming language. It is widely used in educational environments, being relatively easy to learn and applicable to a variety programs.
- It follows a linear approach. It focuses on a set of instructions that are followed through to achieve a desired outcome at the end.
- It consists of high-level, 3rd generation, imperative languages such as Python.
- Structured Programming: This is a type of procedural programming, which uses the programming constructs of sequences, selections, iterations and recursion.
- Procedural Languages have built in simple data types, such as string, char, Boolean, int and real. It may also have data structures such as the Array and Record.
- Program statements can use modular techniques to split large programs into manageable blocks such as Procedures & Functions.
Declarative Programming: This is when you write statements that describe the problem, and the language implementation decides the best way of solving it. This is used in SQL.
Functional Programming: Statements are written as series of functions, which accept input data as arguments and return an output.
Object-Orientated Programming: Program components are split into small units called objects which are used by and interact with other objects in order to build a complex system.
- It is based on the concept of ‘objects’, which can contain data & code. Data will be in the form of fields, which are often known as attributes or properties. Code will be in the form of procedures, which are often known as methods.
- It makes code reusable and programs easy to maintain. The main program is also shorter and easier to write.
- Classes are defined which correspond to ‘objects’ in the real world. It can be considered as a template for new variables.
- Each class has attributes. This is a data value stored in a variable.
- Each class has methods. This is an action that can be carried out by variables of the class.
- Objects are instances of the class. This is the new variable of a class.
Inheritance: This is a mechanism in which one class acquire the property of another class.
- It is when a derived class inherits all the methods and attributes of its parent class/superclass.
- The inheriting class may override some of these methods and attributes and may also have additional extra methods and attributes of its own.
- This means that class can be coded and used as the base for similar objects. This can save programming time.
Polymorphism: This refers to a programming language’s ability to process objects differently depending on their class. Essentially, this means ‘the same command has different effects with different data types or classes’. It is the ability of an object to take on many forms.
This can be done in two ways:
- Overloading: This is when a method is defined in the subclass that has the same name, but different arguments to a method defined in the parent class.
- Overriding: This is when a method is redefined in the subclass with the same name and arguments as the parent class. This essentially overrides the method defined in the superclass.
- This allows the same method to be applied to objects of different classes.
- The code is written to be able to handle different objects in the same way. This reduces the amount of code produced therefore saving time.
- It allows programmers to make a program that will accept any data that they want into a method and it will be able to cope with it.
Encapsulation: This is the principle that concerns how data inside the class can be accessed or changed. This is also known as Information Hiding.
- This means that some methods and attributes can either be public or private.
- Private methods and attributes cannot be used in the main program, whereas public methods and attributes can.
- SET: Allows you to change the value of a private attribute.
- GET: Allows you to use the value of a private attribute.
- Values cannot be accessed in the main program without using the GET and SET procedures.
- It helps to keep objects interacting in the way it was intended and prevents indiscriminate, unexpected changes to attributes as this could have unforeseen consequences. This helps to maintain data integrity.
Assembly Language: This was the first type of programming language to come about after Machine Code Programming. It makes uses of 3 letter mnemonics for key actions. Thus making them easier to remember for a developer.
- The assembler translates the assembly language program into machine code for execution.
- Easier to write than machine code, but more difficult than other High-Level Languages.
|Mnemonic Code:||Instruction:||Numeric Code:||Description:|
|ADD||ADD||1xx||Add the contents of the memory address to the accumulator.|
|SUB||SUBTRACT||2xx||Subtract the contents of the memory address from the accumulator.|
|STA||STORE||3xx||Store the value in the accumulator in the memory address given|
|LDA||LOAD||5xx||Load the accumulator with the contents of the memory address given.|
|BRA||BRANCH||6xx||Branch – use the address given as the address of the next instruction|
|BRZ||BRANCH IF ZERO||7xx||Branch to the address given if the accumulator is 0|
|BRP||BRANCH IF POSITIVE||8xx||Branch to the address given if the accumulator is 0 or positive|
|INP||INPUT||901||Input into the accumulator|
|OUT||OUTPUT||902||Output contents of the accumulator|
|HLT||HALT||0||Stops the execution of the program|
|DAT||DATA||Used to indicate a location that contains data.|
Addressing Modes: The different ways to refer data stored in memory.
- Opcode is the first part of the instruction decoded that specifies what operation the Control Unit needs to perform.
- Opandis the remainder of the computer instruction, which specifies what data is to be manipulated or operated on, while at the same time representing the data itself.
- Immediate Addressing: Data in the operand is the value to be used by the operator.
- Direct Addressing: The operand holds the memory address of the value to be operated on. This is the only addressing mode used in the Little Man Computer assembly language.
- Indirect Addressing: The operand is the location, which holds the address of the data that the user wants. This enables a larger range of addressable locations as it increases the size of the address.
- Indexed Addressing: This uses an Index Register (IR) and an absolute address to calculate addresses to be used. This is done by modifying the address given by adding the number from the Index Register to the address in instruction. This allows efficient access to a range of memory locations by incrementing the value in the Index Register.
151 total views, 1 views today