Chapter 8 The Tower of Babel - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Chapter 8 The Tower of Babel

Description:

A program in procedural language consists of sequences of statements that ... There was an object oriented Pascal created by Borland called Delphi. Eg of PASCAL code ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 21
Provided by: bonita4
Category:
Tags: babel | borland | chapter | tower

less

Transcript and Presenter's Notes

Title: Chapter 8 The Tower of Babel


1
Chapter 8The Tower of Babel
  • Procedural languages
  • Special purpose languages
  • Alternative language paradigms

2
Procedural languages
Special purpose languages
  • SQL
  • Perl
  • HTML

Paradigms
  • Fortran
  • COBOL
  • Pascal
  • C/C
  • Ada
  • Procedural paradigm
  • Functional paradigm
  • Logic paradigm

3
  • Java is not the only HLL.
  • Each programming language meets specific needs.
  • Analogy to cars.
  • We could use Java to write engineering
    applications but it was not designed for that.
  • Example (2.84)1.8 (use Fortran)
  • Sales report use COBOL

4
Procedural languages/ Imperative languages
  • A program in procedural language consists of
    sequences of statements that manipulate data
    items that is they change the contents of memory
    cells.
  • These are called imperative commands
  • They follow the fetch/decode/execute cycle of the
    Von Neumann machine.
  • The fundamental operations are storing and
    retrieving values.
  • Eg. c1 a b-c
  • Examples of procedural languages are Fortran,
    COBOL, Pascal, C/C and Ada.
  • Syntax differs in languages but they all follow
    the same principle.

5
FORTRAN
  • FORmula TRANslation.
  • Good for scientific computation and engineering
    applications.
  • In Java we say
  • Number lt 0
  • In Fortran we say
  • NUMBER .LT. 0
  • Fortran requires variable identifiers to be
    uppercase.
  • Used jumps to simulate while loops in earlier
    versions.
  • GO TO was used (similar to assembly code jump)
  • Use of GOTOs is discouraged results in
    spaghetti code.
  • Difficult to debug and fix errors.

6
COBOL
  • COmmon Business Oriented Language
  • Good for business needs like payroll, inventory.
  • In business applications we have a master file
    and transaction files.
  • Eg. an master inventory file contains names,
    manufacturers and qty for various items of the
    inventory.The master file is updated from
    transaction file daily or weekly.
  • COBOL is very good at handling file input rather
    than keyboard input.
  • Used for producing reports. Does this
    efficiently.
  • COBOL uses very English like statements
  • Eg. sum ab would be written as
  • ADD A to B GIVING SUM
  • COBOL is less formula oriented than FORTRAN since
    it is not a scientific computing language.
  • COBOL programs needed to be fixed for the Y2K.
  • Read page 398 for a description of the Year 2000
    problem.

7
PASCAL
  • Good language to learn programming.
  • Easy to read and learn syntax.
  • Not very cryptic like C/C
  • There was an object oriented Pascal created by
    Borland called Delphi.
  • Eg of PASCAL code
  • IF (A lt 6) and (B gt 10) then
  • writeln(yes)
  • Else
  • writeln(no)

8
C/C
  • C was developed by ATT Bell labs.
  • Designed for writing OS and writing system
    software.
  • C is efficient.
  • Makes use of low level info such as where data is
    stored in memory.
  • So C can shield the programmer or allow direct
    access to hardware.
  • C allows access to a memory cell address as well
    as to its content.
  • To see the address of the memory at which the
    value of an identifier is stored it puts an
    ampersand before the identifier.
  • E.g. Lets say you define a variable Number. Just
    saying number will give you value of number but
    if you say number it will give you the address
    of memory location at which number is located.
  • C has also a data type called pointer.
  • Variables of pointer type contain memory
    addresses instead of the values of the variables.
  • Eg. int intPointer
  • The above will declare intPointer as a pointer
    variable that will contain the address of a
    memory cell containing integer data.
  • Eg. intPointer (int) 800
  • Assigns memory address 800 as the value of
    intPointer.

9
  • C was also developed at ATT Bell labs a decade
    after C was developed.
  • C is a subset of C
  • C is able to do object oriented programming.
  • C code is very similar to Java

10
Ada
  • Lady Ada Lovelace together with Charles Babbage
    worked on the Analytic Engine
  • Ada was regarded as the first programmer.
  • http//www.adahome.com/

11
Special purpose languages
  • SQL Structured Query Language
  • Used with databases
  • A database is a collection of related facts and
    information.
  • Querying a database is important.
  • SQL helps to query a database.
  • A database has tables and each table has rows and
    columns.
  • Example of SQL query
  • SELECT NAME
  • FROM EMPLOYEE
  • WHERE BDATE 02/04/1956

12
Special purpose languages
  • PERL
  • Practical Extraction and Report Language
  • Designed to scan arbitrary text files, extract
    various kinds of information that is contained
    within the text, and print reports based on the
    extracted informaitoan.
  • Based on C syntax.
  • Has good pattern matching techniques.
  • Good for web page scripting.

13
HTML
  • HyperText Markup Language
  • You can write web pages using this.
  • And you can view it in a internet browser i.e.
    internet explorer or netscape.
  • HTML is made up of tags.
  • Overall format is something like this
  • lthtmlgt
  • ltheadgt
  • lttitlegt Title of web page goes here lt/titlegt
  • lt/headgt
  • ltbodygt
  • lt/bodygt
  • lt/htmlgt

14
Procedural paradigm
  • A paradigm is a model for representing a
    programming method of thinking.
  • Procedural paradigm says that a sequence of
    detailed instructions is provided to the
    computer.
  • Each instruction is concerned with accessing and
    modifying contents of memory locations.
  • A procedural paradigm consists of
  • Plan the algorithm
  • Convert the unambiguous and effectively
    computable operations as program instructions.
  • Remember that in OOP, this procedural paradigm
    still works.
  • Next we will look at other types of paradigms.

15
Functional programming paradigm
  • LISP is a functional programming language.
  • Scheme is another.
  • A functional programming language views all tasks
    in terms of functions.
  • Certain functions are called primitives.
  • Other functions are defined by the programmer.
  • Eg.
  • (define (double x)
  • ( 2 x))
  • The function name is double and x is the
    parameter. If we call this function as in (double
    4) what should it output?
  • This is the way complex functions are defined.
  • LISP is another very powerful language that does
    list processing.
  • Eg.
  • (list 1 2 4)
  • (Car (list 1 2 4)) gives 1
  • (Cdr (list 1 2 4)) gives (2 4)
  • This type of programming is good for recursive
    modules. Something that is defined in terms of
    smaller versions of itself. Think of how
    factorial is calculated. What about fibonacci
    numbers?

16
Functional programming paradigm
  • Recursion is one of the features of functional
    programming languages.
  • Procedural languages also support recursion
  • The main benefit of functional paradigm
  • Clarity of thought
  • Free flowing data values
  • No need to worry about intermediate results or
    how many cells of memory a list would occupy.
  • This is another layer of abstraction.
  • There are no side effects in functional
    programming. What is a side effect?
  • If you overwrite a variable you have caused a
    side effect.
  • Impertive/procedural languages have side effects
    by their definition.

17
Logic programming paradigm
  • Functional programming specifies various
    transformations of data
  • Logic programming does not specify how a task is
    to be done. It just says what is to be done.
  • In logic programming you define some facts to be
    true.
  • On the basis of these facts, a logic program can
    infer or deduce other facts.
  • When a query/question is posed to the program, it
    attempts to apply the logical deductions it can,
    to answer the query.
  • Also called declarative languages.
  • Used to write expert system software.
  • Deals a little with artificial intelligence.
  • Prolog is an example of a logic programming
    language.

18
Prolog
  • Prolog programs consist of facts and rules.
  • A fact expresses a property about a single object
    or relationship among several objects.
  • Consider the following prolog code.
  • President(lincoln, gettysburg_address)
  • President(lincoln, civil_war)
  • President(nixon, first_moon_landing)
  • President(jefferson, lewis_and_clark)
  • President(kennedy, cuban_missile_crisis)
  • President(fdr, world_war_II)
  • before(jefferson, lincoln)
  • Before(lincoln,fdr)
  • Before(fdr, kennedy)
  • Before(kennedy, nixon)
  • Now if the user enters
  • ?-before(lincoln, fdr)
  • Prolog will reply yes.
  • What about this?
  • ?-president(lincoln,x)
  • Prolog will reply the following
  • Xgettysburg_address
  • Xcivil_war

19
The logic programming paradigm in a nutshell.
rules
facts
Knowledge Base
Inference engine
query
response
20
  • End of chapter 8
Write a Comment
User Comments (0)
About PowerShow.com