Intro to Low Level High Level Languages and

  • Slides: 36
Download presentation
Intro to -Low Level, High Level Languages -and Object Orientated Programming Topics include: -High

Intro to -Low Level, High Level Languages -and Object Orientated Programming Topics include: -High and Low Level Languages -High level language facilities -Procedural (imperative languages) -Declarative Languages -Languages for ‘real time’ embedded systems -History of OOP -Objects and Classes -Pascal Examples -Encapsulation -Inheritance -Polymorphism -Containment -Event Driven Programming -Benefits of OO Programming

A 2 Computing –Module 4 (JAN 23) ¡ ¡ ¡ ¡ ¡ ¡ Number

A 2 Computing –Module 4 (JAN 23) ¡ ¡ ¡ ¡ ¡ ¡ Number Bases and Representation Binary, OCTAL, HEX Binary Arithmetic Two’s Complement system, negative number representation Interrupts Floating Point Numbers and Normalisation Structure and Role of the Processor Fetch Execute Cycle Structure and Role of the Registers Assembly language instructions Instruction formats and addressing modes (INDRECT, BASE, INDEXED ETC) Low Level Languages High Level Languages & Intro to OO Object Orientated Programming Prolog Programming Recursion Lists/Linked Lists Stacks Queues Trees Searching and Sorting Operating Systems and Concepts Memory/File/I/O Management

Types of Languages HIGH Example: Assembly language LOW Examples: Pascal, Basic, Prolog or C

Types of Languages HIGH Example: Assembly language LOW Examples: Pascal, Basic, Prolog or C

Types of Languages HIGH Examples: Pascal, Basic, Prolog or C High (because we are

Types of Languages HIGH Examples: Pascal, Basic, Prolog or C High (because we are superior to computer) Closer to What we understand (resembling English Statements) LOW Example: Assembly language Closer to what The computer understands (low)

F=False. Which statement's) are false? Characteristics of a Low Level Language ¡ F ¡

F=False. Which statement's) are false? Characteristics of a Low Level Language ¡ F ¡ ¡ ¡ Machine orientated Program written for one machine will work on any other type of machine (with different processor chip) Assembly language statement (apart from macros) translates into one machine code instruction. Programming is therefore quick, non-time consuming and efficient Assembly language used when you need to access machine registers or exact memory adresses Or when you need to write code that executes as fast as possible Occupies as little memory as possible An example with all the above three requirements is a device driver (program which allows computer to interface with printer)

Characteristics of a high level language ¡ ¡ ¡ F* ¡ Not machine orientated

Characteristics of a high level language ¡ ¡ ¡ F* ¡ Not machine orientated In theory –are portable –program written for one machine can run anywhere else (provided compiler, interpreter available) Problem orientated –HLL’s have features and structures that are appropriate to a particular problem. Generally resemble English sentences or maths expressions Easier to understand than assembly language (low level) instructions Each statement in a high level language is translated into one machine code instruction *Into many machine code instructions (as opposed to Low level instructions)

These are not found in low level languages Typical High Level Language facilities If…then….

These are not found in low level languages Typical High Level Language facilities If…then…. else…case; 1. SELECTION STRUCTURE 2. ITERATION STRUCTURES While…endwhile, repeat…until…for Endfor. ASSEMBLY lang must used conditional Branch statements (branch if equal to, etc) 3. BUILT-IN-ROUTINES to simplify input/output Readln, writeln (PASCAL) 4. BUILT-IN-FUNCTIONS Sqr, log, chr; 5. DATA STRUCTURES String, array, Record

Types of High Level Languages Procedural (imperative) Declarative Object Orientated PASCAL, C, COBOL, BASIC.

Types of High Level Languages Procedural (imperative) Declarative Object Orientated PASCAL, C, COBOL, BASIC. FORTRAN COBOL PROLOG JAVA C++ DELPHI Program consists of sequence of instructions which computer executes in order specified by programmer Another class of programming language which consist of SERIES OF FACTS and RULES about a particular subject, rather than sequence of instructions. In this type of language the programmer uses objects, which are data items with all the processing possible on the data item attached to it!

True or false ¡ Declarative languages (like DELPHI) are in which the program consists

True or false ¡ Declarative languages (like DELPHI) are in which the program consists of a sequence of instructions. False Declarative –about rules and facts about a subject rather Than sequence of instructions (eg. PROLOG)

Languages for real-time embedded systems ¡ Computers have become smaller, faster, better, etc. so

Languages for real-time embedded systems ¡ Computers have become smaller, faster, better, etc. so their applications has widened. ¡ One huge area of computer apps is EMBEDDED SYSTEMS ¡ EMBEDDED SYSTEM –the computer is just ONE part of a larger engineering system

Examples of Embedded System

Examples of Embedded System

Old video recorder/player

Old video recorder/player

Process control system for controlling traffic lights

Process control system for controlling traffic lights

Car assembly robot

Car assembly robot

US AIR FORCE C-17 transport aircraft has 19 different embedded computers with 80+ microprocessors

US AIR FORCE C-17 transport aircraft has 19 different embedded computers with 80+ microprocessors on board.

Languages for programming REAL TIME systems need the following facilities ¡ Real time control

Languages for programming REAL TIME systems need the following facilities ¡ Real time control facilities ¡ Ability to act and recognise on the non-occurrence of some external event (temperature sensor in a nuclear (programmers should be able to specify times at which actions are performed, or set regular intervals –i. e every 5 seconds. Electric power station needs to increase supply at 5 PM. Traffic lights may change every 30 seconds or less if oncoming car detected) reactor to log every second. Failure to log after 10 seconds to be reported as a fault) ¡ Should be able to have a timeout facility ¡ Interaction with hardware interfaces ¡ Ability to support concurrent programming (more than one action carried out simultaneously) (programmer can code a time-out facility. i. e what happens when the 10 seconds are up) etc) (sensor detection (languages like C, ADA, Modula-2, OCCAM all contain these facilities)

Structured Programming? ¡ This approach involves decomposing a large problem into smaller problems until

Structured Programming? ¡ This approach involves decomposing a large problem into smaller problems until the smaller problems become solvable.

In structured programming ¡ Smaller problems are coded as Procedures or Functions Data passed

In structured programming ¡ Smaller problems are coded as Procedures or Functions Data passed to these using Parameters (Procedural O P) The thing to remember is that DATA AND PROCEDURES remain TOGETHER. True or false?

FALSE! Structured Programming ¡ Procedural (imperative) Programming (Problems broken down into smaller tasks using

FALSE! Structured Programming ¡ Procedural (imperative) Programming (Problems broken down into smaller tasks using procedures and functions and parameters passing data to the P’s an F’s) ¡ DATA AND PROCEDURES REMAIN SEPARATE!!

Object Orientated programming The world is made up of objects ¡ So OOP models

Object Orientated programming The world is made up of objects ¡ So OOP models the real world more closely ¡ Objects store both data and code for the operations that may be applied to that data. ¡

True or False ¡ Procedural (imperative) and Structural Languages have Data and Procedures that

True or False ¡ Procedural (imperative) and Structural Languages have Data and Procedures that are contained together. False

True or false ¡ In an object orientated language like Visual Basic…. objects store

True or false ¡ In an object orientated language like Visual Basic…. objects store both data and code for the operations that may be applied to that data. True

Procedural Programming languages ¡ PASCAL? True

Procedural Programming languages ¡ PASCAL? True

Some procedural languages Have OO features built in (Object Pascal) ¡ C++ was developed

Some procedural languages Have OO features built in (Object Pascal) ¡ C++ was developed from C by adding OO capability ¡ Java =truly object orientated ¡

So what makes something Object Orientated? ¡ How do we decide if something is

So what makes something Object Orientated? ¡ How do we decide if something is ALIVE? It must fit certain criteria, such as: Criteria for being a living thing -Breathing -Movement -Excretion -Growth -Sensitivity -Reproduction

Criteria for being an OO programming language -Inheritance -Encapsulation -Polymorphism *Abstraction *Containment OBJECTS represent

Criteria for being an OO programming language -Inheritance -Encapsulation -Polymorphism *Abstraction *Containment OBJECTS represent real things from the real world. i. E A CAR. An Object also has ATTRIBUTES. The colour, the shape, the size of the car. These values (attributes) are stored in FIELDS THE CLASS defines what fields it has. The OBJECT stores its own set of values (the state of the object) Objects also have METHODS (operations) like update mileage (this Describes the objects BEHAVIOUR) Each class has SOURCE CODE associated with it –i. e this defines its Details (fields and methods)

Procedural(Imperative)

Procedural(Imperative)

JAVA

JAVA

C

C

Developed for use in scientific And engineering applications in the 1950’s Features that made

Developed for use in scientific And engineering applications in the 1950’s Features that made it suitable For MATHEMATICAL applications -large library of maths functions like log, sin -comprehensive library of stats, scientific And engineering routines -double precision arithmetic (64 bits instead Of 32 bits to represent a real number) which means calculations are done with Greater accuracy -good array handling capabilities So suitable for solving large sets of Simultaneous equations Procedural(Imperative)

Great for Data Processing Applications -good validation facilities -a sort verb to allow files

Great for Data Processing Applications -good validation facilities -a sort verb to allow files to be sorted into Any sequence -excellent file-handling capabilities -good report-formatting features -facility to access database from cobol prog Procedural(Imperative) NEW VERSIONS OF COBOL are OO And have web-based features! Common Business Orientated Language

So how do we chose a Programming Language? ¡ What factors would you consider?

So how do we chose a Programming Language? ¡ What factors would you consider?

So how do we chose a Programming Language? Nature of the application ¡ Availability

So how do we chose a Programming Language? Nature of the application ¡ Availability of facilities within the language for implementing the software design ¡ Availability of a suitable compiler/interpreter for the hardware ¡ The expertise of the programmer ¡