Comp313a programming languages
This presentation is the property of its rightful owner.
Sponsored Links
1 / 33

COMP313A Programming Languages PowerPoint PPT Presentation


  • 133 Views
  • Uploaded on
  • Presentation posted in: General

COMP313A Programming Languages. More Overview. Language Implementation. Language definition syntax, semantics Language translation. Programming Language Design Issues. Programming Language Generations. First Generation: Assembly language

Download Presentation

COMP313A Programming Languages

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Comp313a programming languages

COMP313A Programming Languages

More Overview


Language implementation

Language Implementation

  • Language definition

    • syntax, semantics

  • Language translation


Programming language design issues

Programming Language Design Issues


Programming language generations

Programming Language Generations

  • First Generation: Assembly language

  • Second Generation: Unstructured high-level Languages e.g. Fortran

  • Third Generation: Structured high-level languages e.g. Pascal, C, C++, Ada

  • Fourth Generation: Application-specific languages for building database-oriented systems

  • Fifth Generation: Very high-level languages, especially logic programming languages and other declarative languages. e.g. Prolog


Imperative versus declarative languages

Imperative versus Declarative Languages

  • Imperative programming

    • Comprises a sequence of commands imperatives

  • Declarative programming

    • Declare what results we want and leave the programming language to figure out how to produce them

  • Declarative = “What”

  • Imperative = “How”


Computational paradigms

Computational Paradigms

  • Imperative/procedural

  • Object-oriented

  • Functional

  • Logic


What makes a good language

What Makes a Good language?

  • Page 57 Louden

  • Human criteria

    • Learnability: Is language easy to learn and remember

    • Writable: Easy to write correct programs

    • Readable: Easy to understand programs

    • Maintainable: Easy to change programs


What makes a good language1

What Makes a Good Language…

  • Computer Criteria

    • Implementable: Can language be implemented

    • Efficient: Are programs translated and executed fast enough

    • Portable: Is language available on most computers?


Learnability

Learnability

Design goals for making languages easier to learn and remember:

  • Simplicity.

    • Simple syntax and semantics.

  • Familiarity.

    • Should use standard notations whenever possible.

  • Uniformity.

    • Language constructs that are similar should look and behave similarly.

    • Constructs that are different should look different.


Learnability1

Learnability…

  • Orthogonality

    • Language constructs can be combined in any meaningful way and should not interact in unexpected ways.

  • Generality

    • Have one general construct rather than several specific ones. Avoid restricting the ways constructs can be used.

  • Preciseness

    • Is the language precisely defined?

    • ANSI/ISO.

    • Does it have a formal semantics? Validation suites?


Writability

Writability

Language design goals for writability include:

  • Expressiveness

    • Allows programs to be written in the most natural way. E.g. Build up high-level abstractions

  • Error prevention

    • Language makes some kinds of errors impossible

  • Error Detection

    • Language allows errors to be found and reported. E.g. array bounds checking, arithmetic overflow


Readability understandability

Readability/Understandability

Most of the learnability design goals help readabilty:

  • Expressiveness

    • Can also improve readability if the programmer has used it wisely

  • Document support

    • Essential for understanding large programs

  • Language Environment

    • e.g. browsers, cross-reference tools, pretty printers, debuggers


Maintainability

Maintainability

In addition to the readability and writability design goals, design goals that improve readability include:

  • Machine Independence

    • Ban or isolate machine-specific features

  • Modularity

    • Good modularity constructs allow one part of a program to be changed without impacting other parts


History of programming languages

History of Programming Languages


Jacquard loom early 1800 s

Jacquard Loom (Early 1800’s)

  • Machines for weaving cloth

  • Weaving pattern was programmed by cards / paper tape


Babbage s analytical engine

Babbage’s Analytical Engine

  • Mechanical digital computer (cogs, levers…)

  • Programmed by a sequence of data and operation cards

  • Never fully built, but some programs were written by Ada Lovelace (first programmer)


1940 s languages without machines

1940’s: Languages without Machines

War Computers/Calculators: Colossus, ENIAC

  • Lambda Calculus by Alonzo Church (1941)

    • The basis for functional programming languages

  • Konrad Zuse, a German engineer working alone while hiding out in the Bavarian Alps, develops Plankalkul (1945)


1950 s first implemented hlls

1950’s: first Implemented HLLs

  • Early 1950’s: First few stored program computers working.

    • Mark 1, EDSAC, ACE, EDVAC, UNIVAC 1

  • Small memory machines

  • Programmed in machine code

  • The good old days!!


Grace mary hopper

Grace Mary Hopper

  • Programmer on Mark I, Mark II, and Mark III computers and UNIVAC I, the first large-scale electronic digital computer

  • 1949 began work on first compiler A-0

    • Translated symbolic mathematical code into machine code

  • Then came B-0, later called FLOW-MATIC.

    • automatic billing and payroll calculation

  • Technical advisor to CODASYL responsible for COBOL (1959)


Grace hopper

Grace Hopper…

  • It's easier to ask forgiveness than it is to get permission

  • A ship in port is safe, but that is not what ships are for. Sail out to sea and do new things

  • the most damaging phrase in the language is ‘We've always done it this way’


Fortran 1954 1957

FORTRAN (1954-1957)

  • IBM “FORmula TRANslating system” for IBM 704 computer

  • Major emphasis on compiler producing efficient code

  • Became the major scientific/engineering programming language

  • Much evolution: FORTRAN II, FORTRAN IV, FORTRAN 66, FORTRAN77, FORTRAN90


Overview of fortran iv

Overview of FORTRAN IV

  • Column 1 used to indicate comment lines

  • Column 2-5 used for line numbers (optional)

  • Data: integer, real, arrays (no chars, records or pointers!)

  • Variable declararions are optional (variables starting with I..N are integer, others are real)


Overview of fortran iv1

Overview of FORTRAN IV…

  • Has a three-way if test, goto statements and computed gotos, but no recursion

  • EQUIVALENCE declaration causes variables to be aliased (dangerous!)


Cobol 1959 1960

COBOL (1959-1960)

  • Common Business-Oriented Language

  • Developed in 1959 by a group of computer professionals called the Conference on Data Systems Languages (CODASYL).

  • COBOL was the first programming language whose use was mandated by the US Department of Defense


Cobol

COBOL…

  • English – like verbose syntax (Goal: Human readability)

  • Largely ignored by the academic community

  • And if you thought COBOL was dead…

    Think again..

    Object-oriented COBOL is a subset of COBOL 97, which is the fourth edition in the continuing evolution of ANSI/ISO standard COBOL


Comp313a programming languages

000100 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. HELLOWORLD.

000300

000400*

000500 ENVIRONMENT DIVISION.

000600 CONFIGURATION SECTION.

000700 SOURCE-COMPUTER. RM-COBOL.

000800 OBJECT-COMPUTER. RM-COBOL.

000900

001000 DATA DIVISION.

001100 FILE SECTION.

001200

100000 PROCEDURE DIVISION.

100100

100200 MAIN-LOGIC SECTION.

100300 BEGIN.

100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS. 100500 DISPLAY "Hello world!" LINE 15 POSITION 10. 100600 STOP RUN.

100700 MAIN-LOGIC-EXIT.

100800 EXIT.


Algol 60 1958 1960

ALGOL 60 (1958-1960)

  • ALGOrithmic Language: general expressive language for describing algorithms

  • Used widely in Europe and academia in USA

  • Modern syntax: defined using BNF, free format, structure statements, with begin/end pairs

  • Type declarations required for all variables


Algol60

ALGOL60…

  • Introduced recursion, call-by-name and call-by-value

  • Required stack-based runtime environment

  • Huge influence on later languages: Pascal, C, Module-2, Ada etc


Call by name

Call-by-name

  • Page 321 Louden

  • The argument is not evaluated until its actual use (as a parameter) in the called procedure

  • The name of the argument replaces the name of the parameter it corresponds to


Call by name1

Call-by-name

void inc(int x)

{x++}

inc(a[5]); inc(a[i]);


Call by name2

Call-by-name

int i;

int a[10];

void inc(int x)

{ i++;

x++;

}

main()

{ i = 1;

a[1] = 1

a[2] = 2;

p(a[i]);

return(0);

}


Lisp 1956 1962

LISP (1956-1962)

  • The first functional language

  • The first language to include garbage collection

  • Intended for list processing and symbolic manipulation

  • Syntax was radically different – lots of parentheses

  • Efficiency not a huge concern. Ideas more important

  • Still heavily used today for AI research and applications

  • IDE


Comp313a programming languages

Reverse a list

(Defun reverse (x)

(cond ((null x) NIL)

(T (append (reverse (rest start))

(list (first start))))))


  • Login