Chapters 1 & 2

Chapters 1 & 2

Chapters 1 & 2 Preliminaries ISBN 0-321-19362-8 Chapter 1 Topics • Motivation • Programming Domains • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Methods • Programming Environments Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-2 Motivation Why Study Programming Languages? • Increased ability to express ideas • Improved background for choosing appropriate languages • Greater ability to learn new languages • Understand significance of implementation • Ability to design new languages • Overall advancement of computing Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-3 Programming Domains • Scientific applications – Large number of floating point computations • Business applications – Produce reports, use decimal numbers and characters • Artificial intelligence – Symbols rather than numbers manipulated. Code = Data. • Systems programming – Need efficiency because of continuous use. Low-level control. • Scripting languages – Put a list of commands in a file to be executed. Glue apps. • Special-purpose languages – Simplest/fastest solution for a particular task. Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-4 Language Evaluation Criteria • Readability • Writability • Reliability •Cost •Others Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-5 Language Evaluation Criteria Readability • Overall simplicity – Too many features is bad – Multiplicity of features is bad • Orthogonality – Makes the language easy to learn and read – Meaning is context independent – A relatively small set of primitive constructs can be combined in a relatively small number of ways – Every possible combination is legal – Lack of orthogonality leads to exceptions to rules Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-6 Language Evaluation Criteria Writability • Simplicity and orthogonality • Support for abstraction • Expressiveness Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-7 Language Evaluation Criteria Reliability • Type checking • Exception handling • Aliasing • Readability and writability Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-8 Language Evaluation Criteria •Cost – Categories • Training programmers to use language • Writing programs • Compiling programs • Executing programs • Language implementation system • Reliability • Maintaining programs • Others: portability, generality, well-definedness Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-9 Influences on Language Design • Computer architecture: Von Neumann • We use imperative languages, at least in part, because we use von Neumann machines – Data and programs stored in same memory – Memory is separate from CPU – Instructions and data are piped from memory to CPU – Basis for imperative languages • Variables model memory cells • Assignment statements model piping • Iteration is efficient Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-10 Von Neumann Architecture Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-11 Influences on Language Design • Programming methodologies – 1950s and early 1960s: Simple applications; worry about machine efficiency – Late 1960s: People efficiency became important; readability, better control structures • Structured programming • Top-down design and step-wise refinement – Late 1970s: Process-oriented to data-oriented • data abstraction – Middle 1980s: Object-oriented programming Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-12 Language Categories • Imperative – Central features are variables, assignment statements, and iteration – FORTRAN, C, Pascal • Functional – Main means of making computations is by applying functions to given parameters – LISP, Scheme Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-13 Language Categories •Logic – Rule-based – Rules are specified in no special order –Prolog • Object-oriented – Encapsulate data objects with processing – Inheritance and dynamic type binding – Grew out of imperative languages –C++, Java Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-14 Some Language Design Trade-Offs • Reliability vs. cost of execution • Readability vs. writability • Flexibility vs. safety Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-15 Layered View of Computer Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-16 Implementation Methods • Compilation – Translate high-level program to machine code – Slow translation – Fast execution Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-17 Compilation Process Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-18 Implementation Methods • Pure interpretation – No translation – Slow execution – Becoming rare Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-19 Implementation Methods • Hybrid implementation systems – Small translation cost – Medium execution speed –Portable Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-20 Programming Environments • The collection of tools used in software development • UNIX – An older operating system and tool collection • Borland JBuilder – An integrated development environment for Java • Microsoft Visual Studio.NET – A large, complex visual environment – Used to program in C#, Visual BASIC.NET, Jscript, J#, or C++ Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-21 Genealogy of Common Languages Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-22 Zuse’s Plankalkül - 1945 • Never implemented • Advanced data structures – floating point, arrays, records •Invariants Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-23 Plankalkül • Notation: A[7] = 5 * B[6] | 5 * B => A V | 6 7 (subscripts) S | 1.n 1.n (data types) Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-24 Pseudocodes - 1949 • What was wrong with using machine code? – Poor readability – Poor modifiability – Expression coding was tedious – Machine deficiencies--no indexing or floating point Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-25 Pseudocodes • Short code; 1949; BINAC; Mauchly – Expressions were coded, left to right – Some operations: 1n => (n+2)nd power 2n => (n+2)nd root 07 => addition Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-26 Pseudocodes • Speedcoding; 1954; IBM 701, Backus – Pseudo ops for arithmetic and math functions – Conditional and unconditional branching – Autoincrement registers for array access –Slow! – Only 700 words left for user program Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-27 Pseudocodes • Laning and Zierler System - 1953 – Implemented on the MIT Whirlwind computer – First "algebraic" compiler system – Subscripted variables, function calls, expression translation – Never ported to any other machine Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-28 IBM 704 and FORTRAN • FORTRAN I - 1957 (FORTRAN 0 - 1954 - not implemented) – Designed for the new IBM 704, which had index registers and floating point hardware – Environment of development: • Computers were small and unreliable • Applications were scientific • No programming methodology or tools • Machine efficiency was most important Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-29 IBM 704 and FORTRAN • Impact of environment on design of FORTRAN I – No need for dynamic storage – Need good array handling and counting loops – No string handling, decimal arithmetic, or powerful input/output (commercial stuff) Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-30 IBM 704 and FORTRAN • First implemented version of FORTRAN – Names could have up to six characters – Post-test counting loop (DO) – Formatted I/O – User-defined subprograms – Three-way selection statement (arithmetic IF) – No data typing statements Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-31 IBM 704 and FORTRAN • First implemented version of FORTRAN – No separate compilation – Compiler released in April 1957, after 18 worker- years of effort – Programs larger than 400 lines rarely compiled correctly, mainly due to poor reliability of the 704 – Code was very fast – Quickly became widely used Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-32 IBM 704 and FORTRAN • FORTRAN II - 1958 – Independent compilation – Fix the bugs Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-33 IBM 704 and FORTRAN • FORTRAN IV - 1960-62 – Explicit type declarations – Logical selection statement – Subprogram names could be parameters – ANSI standard in 1966 Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-34 IBM 704 and FORTRAN • FORTRAN 77 - 1978 – Character string handling – Logical loop control statement – IF-THEN-ELSE statement Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-35 IBM 704 and FORTRAN • FORTRAN 90 - 1990 – Modules – Dynamic arrays – Pointers – Recursion – CASE statement – Parameter type checking Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-36 LISP - 1959 • LISt Processing language (Designed at MIT by McCarthy) • AI research needed a language that: – Process data in lists (rather than arrays) – Symbolic computation (rather than numeric) • Only two data types: atoms and lists • Syntax is based on lambda calculus • Same syntax for data and code Copyright © 2004 Pearson Addison-Wesley. All rights reserved. 1-37 Representation of Two LISP Lists

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    75 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us