sd & d types of programming language

15
Types of programming language

Upload: forrester-high-school

Post on 19-Aug-2015

55 views

Category:

Education


4 download

TRANSCRIPT

Types of programming language

Types of programming languageThere are 3 types of programming language:

1.Procedural

2.Declarative

3.Object-Oriented

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)

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

Procedural languagesBASIC listing

Procedural languagesPython listing

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

Declarative languagesSample PROLOG listing

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

Classes

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

Instances

InheritanceObject-oriented programming allows classes to inherit

commonly used state and behaviour from other classes

Inheritance

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