1 / 24

CS 326 Programming Languages, Concepts and Implementation

CS 326 Programming Languages, Concepts and Implementation. Instructor: Mircea Nicolescu Lecture 1. Contacts. Instructor: Dr. Mircea Nicolescu E-mail: mircea@cse.unr.edu Office: SEM 232 Office Hours: Tuesday: 9:00am-12:00pm Class web page: http://www.cse.unr.edu/~mircea/Teaching/cs326.

Download Presentation

CS 326 Programming Languages, Concepts and Implementation

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. CS 326Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 1

  2. Contacts • Instructor: Dr. Mircea Nicolescu • E-mail: mircea@cse.unr.edu • Office: SEM 232 • Office Hours: Tuesday: 9:00am-12:00pm • Class web page: • http://www.cse.unr.edu/~mircea/Teaching/cs326

  3. Assignments and Exams • Homework assignments (40%) • Written exercises and small programs • More complex programs, in Scheme, Prolog, Java or ML • Midterm exam (25%) • Closed book, closed notes • Final exam (30%) • Closed book, closed notes • Comprehensive, although focused on the second half of the course • Attendance and class participation (5%)

  4. Late Submission Policy • No late assignments will be accepted Warning: Dates in the calendar are closer than they appear!

  5. Required Textbook • Programming Language Pragmatics, by Michael L. Scott, Morgan Kaufmann Press, 2009.

  6. What Are We Studying? • Programming languages characterized by: • Syntax – what a program looks like • Semantics – what a program means • Implementation – how a program executes • Trade-offs between design (specifying syntax and semantics) and implementation • Will focus on these concepts, illustrated by various languages, and not on the languages themselves

  7. Why Study Programming Languages? • Help you choose a language • Systems programming → C, Modula-3 • Scientific computations → Fortran, Ada • Embedded systems → C, Ada, Modula-2 • Symbolic computing → Lisp, Scheme, ML • Make it easier to learn new languages • Some languages are similar • Some concepts are even more similar: iteration, recursion, abstraction

  8. Why Study Programming Languages? • Make better use of the languages you know • Improve ability to develop effective algorithms • Understand obscure features • Understand implementation costs • Simulate useful features in languages that do not support them • Prepare for further study in language design and implementation (compilers) • Help understand other system software (assemblers, linkers, debuggers)

  9. Historic Perspective • When did the earliest high-level languages appear? • Continuous evolution since the 1950s (Fortran, Cobol) • When the Department of Defense did a survey as part of its efforts to develop Ada in the 1970s, how many languages did it find in use? • Over 500 languages were being used in various defense projects

  10. Architecture Evolution • 1950s – Large expensive mainframe computers ran single programs (Batch processing) • 1960s – Interactive programming (time-sharing) on mainframes • 1970s – Development of microcomputers. Early work on windows, icons, and PCs at XEROX PARC • 1980s – Personal computer: IBM PC and Apple Macintosh. Use of windows, icons and mouse • 1990s – Client-server computing - networking, the Internet, the World Wide Web

  11. Spectrum of Languages • Imperative (“how should the computer do it?”) • Von Neumann: Fortran, Basic, Pascal, C • Computing via “side-effects” (modification of variables) • Object-oriented: Smalltalk, Eiffel, C++, Java • Interactions between objects, each having an internal state and functions which manage that state • Declarative (“what should the computer do?”) • Functional: Lisp, Scheme, ML, Haskell • Program ↔ application of functions from inputs to outputs • Inspired from lambda-calculus (Alonzo Church) • Logic, constraint-based: Prolog • Specify constraints / relationships, find values that satisfy them • Based on propositional logic

  12. Why Are There So Many Languages? • Evolution • We have learned better ways of doing things over time • Socio-economic factors • Proprietary interests, commercial advantage • Special purposes • Special hardware • Personal preference

  13. What Makes a Language Successful? • Easy to learn • Basic, Pascal • Easy to express things • “Powerful” • Easy to use once known • C, Lisp • Easy to implement • Small machines, limited resources • Basic, Forth

  14. What Makes a Language Successful? • Efficient compilers • Generate small / fast code • Fortran • Backing of a powerful sponsor • Ada, Visual Basic • Wide dissemination at a minimal cost • Pascal, Java • Inertia • Fortran, Cobol

  15. Standardization • Is i = 1 && 2 + 3 | 4; legal in C? • What is assigned to i if it is? • 3 ways to answer this: • Read language manual (Problem: Can you find one?) • Read language standard (Problem: Have you ever seen it?) • Write a program to see what happens. (Easy to do!) • Most do the last, but different compilers may give different answers

  16. Standardization • Language standards defined by: • ISO - International Standards Organization • IEEE - Institute of Electrical and Electronics Engineers • ANSI - American National Standards Institute • Contentious features omitted to gain consensus • Nothing is enforced

  17. Standardization • When to standardize a language: • If too late – many incompatible versions already exist (Fortran in 1960) • If too early – no experience with language (Ada in 1983 had no running compilers yet) • Just right – probably Pascal in 1983, although it is rapidly becoming a dead language • Other languages: • C in 1988 • LISP in 1990 – way too late • De facto standards: ML – one major implementation: SML • Smalltalk, Prolog – none

  18. Standardization • Internationalization: • How many bits to use for characters • Additional letters (German ä, French é) • Other alphabets (Cyrillic, Greek, Arabic, Chinese) • Organization that studies this problem cannot even decide between internationalization and internationalisation for its own name • Other internationali*ation issues: • Dates, times, daylight saving time • Currency

  19. afbf0015 A Simple Program Compute greatest common divisor of 2 integers: • Machine language • Sequence of bits that directly controls the processor • Add, compare, move data, etc. • Computer’s time more valuable than programmers’ time

  20. A Simple Program • Assembly language • Mnemonic abbreviations, 1-to-1 correspondence to machine language • Translated by an assembler • Still machine-dependent

  21. Compilation and Interpretation • Need for: • Machine-independent language • Resemblance between language and mathematical computation • High-level languages (the first: Fortran, Lisp) • Translated by a compiler or interpreter • No more 1-to-1 correspondence to machine language • Accepted when compilers could produce efficient code • Today: efficient compilers, large programs, high maintenance costs, rapid development requirements • Labor cost higher than hardware cost

  22. Compilation and Interpretation • Compiler translates into target language (machine language), then goes away • The target program is the locus of control at execution time • Interpreter stays around at execution time • Implements a virtual machine whose machine language is the high-level language

  23. Compilation and Interpretation • Interpretation • Greater flexibility, better diagnostics • Allow program features (data types or sizes) to depend on the input • Lisp, Prolog: program can write new pieces of itself and execute them on the fly • Java: compilation, then interpretation • Compilation • Better performance • Many decisions are made only once, at compile time, not at every run time • Fortran, C

  24. Readings • Chapter 1

More Related