Top Banner
Types of programming language
15
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SD & D Types of programming language

Types of programming language

Page 2: SD & D Types of programming language

Types of programming languageThere are 3 types of programming language:

1.Procedural

2.Declarative

3.Object-Oriented

Page 3: SD & D Types of programming language

Procedural languages In a procedural language, the programmer specifies the

sequence of operations to be performed

A procedural program has a clear start point, and end point

Livecode, Python, BASIC and C are examples of procedural programming languages (although LiveCode can also be described as Event Driven)

Page 4: SD & D Types of programming language

Procedural languages Larger programs are broken down into smaller

subprograms, known as functions or procedures

Subprograms should have a specific purpose. Using subprograms means a program is modular.

Procedural languages provide the programmer with variable data types such as integers, real numbers and strings

Page 5: SD & D Types of programming language

Procedural languagesBASIC listing

Page 6: SD & D Types of programming language

Procedural languagesPython listing

Page 7: SD & D Types of programming language

Declarative languagesThe programmer declares all of the facts and rules at the

outset

Queries can then be performed on the facts and relationships in order to solve problems

Used in medical diagnosis, weather forecasting, financial projection and planning

Examples are PROLOG and LISP. Declarative languages are often used in artificial intelligence

Page 8: SD & D Types of programming language

Declarative languagesSample PROLOG listing

Page 9: SD & D Types of programming language

Object-oriented languagesIn object-oriented programming (OOP) the language is

modelled around objects rather than actions

Objects can have attributes and methods

A car object can have the attributes:ColourEngine sizeNumber of doors

A car object can have the methods:Drive forwardBrakeUnlock doors

Page 10: SD & D Types of programming language

Classes

Page 11: SD & D Types of programming language

ClassesIn OOP we define a class as the blueprint for our objects

In our example, car is a class – it is not a specific make or model of car but a blueprint for all cars

We use our class to create an instance of an object

Page 12: SD & D Types of programming language

Instances

Page 13: SD & D Types of programming language

InheritanceObject-oriented programming allows classes to inherit

commonly used state and behaviour from other classes

Page 14: SD & D Types of programming language

Inheritance

Page 15: SD & D Types of programming language

EncapsulationEncapsulation is the principle of placing data (attributes)

and functions (methods) into a single component (class)

Using encapsulation we can hide much of the functionality and data from parts of the program that don’t need to access it