1.2.4 Types of Programming Language

Cards (62)

  • Types of Programming Language
    • Programming paradigms
    • Procedural languages
    • Assembly language
    • Modes of addressing memory
    • Object-oriented languages
  • Programming paradigms
    Different approaches to using a programming language to solve a problem
  • Programming paradigms
    • Imperative
    • Declarative
  • Imperative programming paradigm
    • Procedural
    • Object-oriented
  • Imperative programming paradigms
    • Use code that clearly specifies the actions to be performed
  • Procedural programming
    • Can be applied to a wide range of problems and is relatively easy to write and interpret
    • Uses a sequence of instructions which may be contained within procedures
    • Instructions are carried out in a step-by-step manner
  • Procedural programming
    • Pascal
    • Python
    • Logo
  • Object-oriented programming
    • Applicable to certain types of problem with lots of reusable components which have similar characteristics
    • Built on entities called objects formed from classes which have certain attributes and methods
    • Focuses on making programs that are reusable and easy to update and maintain
  • Object-oriented programming
    • Python
    • Delphi
    • Java
  • Declarative programming
    • Focuses on stating the desired result rather than the exact series of instructions that need to be performed to get to the result
    • Common in expert systems and artificial intelligence
  • Functional programming
    • Uses the concept of reusing a set of functions
    • Closely linked to mathematics
  • Functional programminglanguages
    • Haskell
    • C#
    • Java
  • Logic programming
    • Uses code which defines a set of facts and rules based on the problem
    • Queries are used to find answers to problems
  • Procedural programming is used for a wide range of software development as it is very simple to implement
  • It is not possible to solve all kinds of problems with procedural languages or it may be inefficient to do so
  • Procedural languages
    • Use traditional data types such as integers and strings which are built into the language
    • Provide data structures like dictionaries and arrays
    • Structured programming is a popular subsection in which the control flow is given by
  • Procedural languages
    • Use traditional data types such as integers and strings, provide data structures like dictionaries and arrays
  • Structured programming
    • Control flow is given by four main programming structures: Sequence, Selection, Iteration, Recursion
  • Sequence
    Code is executed line-by-line, from top to bottom
  • Selection
    A certain block of code is run if a specific condition is met, using IF statements
  • Iteration
    A block of code is executed a certain number of times or while a condition is met. Iteration uses FOR, WHILE or REPEAT UNTIL loops
  • Recursion
    Functions are expressed in terms of themselves. Functions are executed, calling themselves, until a certain condition known as a base case is met
  • Procedural programming is suited to problems that can easily be expressed as a series of instructions using the constructs described above
  • Assembly language is the next level up from machine code and is part of a family of low-level languages
  • Assembly language uses mnemonics rather than binary, which makes it easier to use than direct machine code
  • Each mnemonic in assembly language is represented by a numeric code
  • Commands in assembly language are processor-specific as it directly interacts with the CPU's special purpose registers
  • Assembly language allows for direct interaction with hardware and is useful in embedded systems
  • Each instruction in assembly language is equivalent to almost one line of machine code
  • Assembly language mnemonics
    • ADD
    • SUB
    • STA
    • LDA
    • INP
    • OUT
    • HLT
    • DAT
    • BRZ
    • BRP
    • BRA
  • Machine code instructions are made up of two parts: the opcode and operand. The opcode specifies the instruction to be performed from the table above. The operand holds a value related to the data on which the instruction is to be performed
  • In some cases, the operand may hold the actual value on which the instruction is to be executed, but more often, it holds an add
  • Addressing modes
    1. Immediate Addressing: The operand is the actual value upon which the instruction is to be performed, represented in binary
    2. 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
    3. Indirect Addressing: The operand gives the address of a register which holds another address, where the data is located
    4. 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
  • Class
    A template for an object and defines the state and behaviour of an object
  • State
    Given by attributes which give an object’s properties
  • Behaviour
    Defined by the methods associated with a class, which describe the actions it can perform
  • Instantiation
    Creating objects using a class
  • Object
    A particular instance of a class
  • A class can be used to create multiple objects with the same set of attributes and methods
  • Setter
    A method that sets the value of a particular attribute