1 / 33

COMP313A Programming Languages

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

olesia
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP313A Programming Languages More Overview

  2. Language Implementation • Language definition • syntax, semantics • Language translation

  3. Programming Language Design Issues

  4. 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

  5. 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”

  6. Computational Paradigms • Imperative/procedural • Object-oriented • Functional • Logic

  7. 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

  8. 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?

  9. 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.

  10. 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?

  11. 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

  12. 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

  13. 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

  14. History of Programming Languages

  15. Jacquard Loom (Early 1800’s) • Machines for weaving cloth • Weaving pattern was programmed by cards / paper tape

  16. 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)

  17. 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)

  18. 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!!

  19. 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)

  20. 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’

  21. 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

  22. 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)

  23. 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!)

  24. 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

  25. 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

  26. 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.

  27. 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

  28. 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

  29. 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

  30. Call-by-name void inc(int x) {x++} inc(a[5]); inc(a[i]);

  31. 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); }

  32. 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

  33. Reverse a list (Defun reverse (x) (cond ((null x) NIL) (T (append (reverse (rest start)) (list (first start))))))

More Related