cs 326 programming languages, concepts and implementation

21
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 1

Upload: socorro-xovi

Post on 15-Mar-2016

57 views

Category:

Documents


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: CS 326 Programming Languages, Concepts and Implementation

CS 326Programming Languages, Concepts

and Implementation

Instructor: Mircea Nicolescu

Lecture 1

Page 2: CS 326 Programming Languages, Concepts and Implementation

22/69

Contacts• Instructor: Dr. Mircea Nicolescu

− E-mail: [email protected]− Office: SEM 232− Office Hours: Thursday: 10:30am-1:30pm

• Class web page:− http://www.cse.unr.edu/~mircea/Teaching/cs326

Page 3: CS 326 Programming Languages, Concepts and Implementation

33/69

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%)

Page 4: CS 326 Programming Languages, Concepts and Implementation

44/69

• No late assignments will be accepted

Late Submission Policy

Warning:

Dates in the calendar are closer than they appear!

Page 5: CS 326 Programming Languages, Concepts and Implementation

55/69

Required Textbook

• Programming Language Pragmatics, by Michael L. Scott, Morgan Kaufmann Press, 2015.

Page 6: CS 326 Programming Languages, Concepts and Implementation

66/69

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

Page 7: CS 326 Programming Languages, Concepts and Implementation

77/69

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

Page 8: CS 326 Programming Languages, Concepts and Implementation

88/69

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)

Page 9: CS 326 Programming Languages, Concepts and Implementation

99/69

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

Page 10: CS 326 Programming Languages, Concepts and Implementation

1010/69

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

Page 11: CS 326 Programming Languages, Concepts and Implementation

1111/69

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

Page 12: CS 326 Programming Languages, Concepts and Implementation

1212/69

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

Page 13: CS 326 Programming Languages, Concepts and Implementation

1515/69

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

Page 14: CS 326 Programming Languages, Concepts and Implementation

1616/69

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

Page 15: CS 326 Programming Languages, Concepts and Implementation

1717/69

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

Page 16: CS 326 Programming Languages, Concepts and Implementation

1818/69

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

Page 17: CS 326 Programming Languages, Concepts and Implementation

1919/69

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

Page 18: CS 326 Programming Languages, Concepts and Implementation

2020/69

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

Page 19: CS 326 Programming Languages, Concepts and Implementation

2121/69

A Simple Program

Compute greatest common divisor of 2 integers:

afbf0015

• Machine language− Sequence of bits that directly controls the processor− Add, compare, move data, etc.− Computer’s time more valuable than programmers’ time

Page 20: CS 326 Programming Languages, Concepts and Implementation

2222/69

A Simple Program

• Assembly language− Mnemonic abbreviations, 1-to-1 correspondence to

machine language− Translated by an assembler− Still machine-dependent

Page 21: CS 326 Programming Languages, Concepts and Implementation

2323/69

Readings

• Chapter 1