Docsity

Slides on Course Introduction | Programming Languages and Compilers | CS 421, Study notes of Computer Science

Toggle sidebar
bg1
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
CS421 Lecture 1: Course Introduction1
Mark Hills
University of Illinois at Urbana-Champaign
May 30, 2006
1Based on slides by Mattox Beckman, as updated by Vikram Adve, Gul
Agha, and Elsa Gunter. Figures from Concepts of Programming Languages,
Seventh Edition, by Robert W. Sebesta
Mark Hills CS421 Lecture 1: Course Introduction
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Welcome to CS 421!
Mark Hills CS421 Lecture 1: Course Introduction
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Mark Hills CS421 Lecture 1: Course Introduction
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Today’s Objectives
Your goal for this lecture is to.. .
Ilearn about who is teaching the class;
Ilearn some of the course mechanics;
Ifind out why this is important material to understand;
Ilearn some about the history of programming languages;
Ilearn how to classify and evaluate languages;
Igain a high-level understanding of how languages are executed.
Mark Hills CS421 Lecture 1: Course Introduction
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Contact Info
References
Resources
Contact Info – Mark Hills (Instructor)
IOffice: 2111A SC
IOffice Hours: Thursdays 2:00 PM - 3:30 PM (or by
appointment)
Mark Hills CS421 Lecture 1: Course Introduction
Outline
Objectives for Today
Administrivia
Grading and Homeworks
Motivation and History
Language Design
Language Implementation
Contact Info
References
Resources
Contact Info – Ben Hilldore (TA)
IOffice: TBD
IOffice Hours (On-Campus): TBA
IOffice Hours (I2CS): Tuesday 6:30 PM - 7:30 PM, Thursday
1:00 PM - 2:00 PM
Mark Hills CS421 Lecture 1: Course Introduction
pf3
pf4
pf5
pf8

Partial preview of the text

Download Slides on Course Introduction | Programming Languages and Compilers | CS 421 and more Study notes Computer Science in PDF only on Docsity!

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

CS421 Lecture 1: Course Introduction

Mark Hills

[email protected]

University of Illinois at Urbana-Champaign

May 30, 2006

Based on slides by Mattox Beckman, as updated by Vikram Adve, Gul

Agha, and Elsa Gunter. Figures from Concepts of Programming Languages,

Seventh Edition, by Robert W. Sebesta

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Welcome to CS 421!

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Objectives for Today

Administrivia

Grading and Homeworks

Motivation and History

Language Design

Language Implementation

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Today’s Objectives

Your goal for this lecture is to...

I learn about who is teaching the class;

I learn some of the course mechanics;

I find out why this is important material to understand;

I learn some about the history of programming languages;

I learn how to classify and evaluate languages;

I gain a high-level understanding of how languages are executed.

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

Contact Info – Mark Hills (Instructor)

I Office: 2111A SC

I Office Hours: Thursdays 2:00 PM - 3:30 PM (or by

appointment)

I Email: [email protected]

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

Contact Info – Ben Hilldore (TA)

I Office: TBD

I Office Hours (On-Campus): TBA

I Office Hours (I2CS): Tuesday 6:30 PM - 7:30 PM, Thursday

1:00 PM - 2:00 PM

I Email: [email protected]

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

Course References

No required textbook

I (^) Compilers: Principles, Techniques, and Tools (”The Dragon

Book”), by Aho, Sethi, and Ullman

I (^) Programming Language Pragmatics (2nd Edition), by Michael

L. Scott

I Concepts of Programming Languages (7th Edition), by Robert

W. Sebesta

I (^) Essentials of Programming Languages (2nd Edition), by

Friedman, Wand, and Haynes

I (^) Other books, papers, etc will be mentioned as we go...

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

Electronic Resources

Course Web Page http://www.cs.uiuc.edu/class/cs421/.

You are expected to check the announce page daily.

News group class.cs

You should read the news group daily also.

Languages OCaml, a dialect of ML.

See http://caml.inria.fr/ocaml

Computer Lab EWS labs: http://www.ews.uiuc.edu/

NOTE: Contact the TAs if you do not have an EWS

account.

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

Course Website

I (^) Main has important news, links elsewhere

I (^) Policy has rules governing the course – read this!

I (^) Lectures has links to the lecture slides, plus old lectures

I (^) MPs has info on the homeworks

I (^) Exams has info on exams, past exams, and useful info to help

prepare

I (^) Unit Projects has info on projects for students registered for 4

hours

I (^) Resources has links to helpful information

I (^) FAQ has answers to some common course questions

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Contact Info References Resources

CS421 Best Practices

I (^) Check the course web page and course news group daily.

I (^) Attend lectures regularly and participate actively.

I (^) Come to office hours and ask questions!

I (^) Do the programming assignments thoroughly: they are critical

I (^) Start an MP the day after it is out, not day before it is due!!

I (^) Take responsibility and initiative in learning material —

work out practice questions; do some OCaml programming;

read another text (e.g., EOPL or Scott)

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Grades Course Homework Unit Project

Course Grading

I (^) MPs (Machine Problems): 35% of grade, submitted

electronically

I (^) Midterm: 25%, in class June 29th

I (^) Final: 40%, August 5th

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Grades Course Homework Unit Project

Course Homework

I (^) You may discuss homeworks and their solutions with others

I (^) You may not leave the discussion with a written solution

I (^) You must write your own solution

I (^) You may not look at another written solution when writing

your own – but you may look at provided examples from class

and other similar examples

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Imperative Languages

I (^) Main focus: machine state the set of values stored in memory

locations

I Command-driven: Each statement uses current state to

compute a new state

I (^) Syntax: S1; S2; S3; ...

I (^) Example languages: C, Pascal, FORTRAN, COBOL, CLU,

Ada

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Imperative Languages, C

1 while (b > 0) {

2 a = a * 2;

3 b = b - 1;

4 }

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Imperative Languages, CLU

2

1 Poly = cluster is create, degree, coeff, ....

2 rep = record[coeffs: array[int], lo, hi: int]

3 create = proc(c,n : int) returns (Poly)

4 A : array[int] := array[int]$create(0)

5 A[n] := c

6 return(up(rep${coeffs: A, lo: n, hi: n}))

7 end create

from Sam Kamin’s Programming Languages: An Interpreter Based

Approach

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Object-Oriented Languages

Classes are complex data types grouped with operations (methods)

for creating, examining, and modifying elements (objects);

subclasses include (inherit) the objects and methods from

superclasses

I (^) Computation is based on objects sending messages (methods

applied to arguments) to other objects

I (^) Syntax: Varies, object ← method(args)

I (^) Example languages: Java, C++, Smalltalk, Simula-67, Beta

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Object-Oriented Languages, C++

1 class Square {

2 public:

3 int x,y,h,l;

4 Square() { x = y = h = l = 0; }

5 };

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Object-Oriented Languages, Beta

1 (#

2 do

3 ’Hello world!’ -> putline

4 #)

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Applicative/Functional Languages

Programs as functions that take arguments and return values;

arguments and returned values may be functions

I (^) Programming consists of building the function that computes

the answer; function application and composition main

method of computation

I (^) Syntax: P1(P2(P3 X))

I (^) Example languages: ML, LISP, Scheme, Haskell, Miranda,

Clean, Erlang

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Applicative/Functional Languages, OCaml

1 # let twice f x = f(f(x));;

2 # let inc x = x + 1;;

3 # inc 5;;

4 6

5 # twice inc 5;;

6 7

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Logic/Rule-based Languages

I (^) Programs as sets of basic rules for decomposing problem

I Computation by deduction: search, unification and

backtracking main components

I (^) Syntax: Answer : − specification rule

I (^) Example languages: Prolog, Datalog, BNF Parsing

1 - human(socrates).

2 - mortal(X) :- human(X).

3 -? mortal(Who).

4 Who = socrates

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Themes in Language Development

I (^) Languages have become more abstract – abstraction of data,

memory, machine errors, execution, etc

I Languages have shifted performance burden to compilers –

machines used to be expensive, now people are

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Evaluation Criteria

3

I (^) Readability

I (^) Writability

I (^) Reliability

I (^) Cost

From Concepts of Programming Languages, 7th Edition, by Robert W.

Sebesta

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Classification of Languages Themes in Language Development Language Evaluation

Readability

I (^) Overall Simplicity

I (^) Orthogonality

I (^) Control Statements (Structured Control vs. Gotos)

I (^) Flexible Data Types and Structures

I (^) Flexible, Consistent Syntax (identifiers, keywords, consistency)

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Virtual Machines

I (^) At first, programs written in assembly language (or at very

first, machine language)

I (^) Hand-coded to be very efficient

I (^) Now, no longer write in native assembly language

I (^) Use layers of software (eg operating system)

I (^) Each layer makes a virtual machine in which the next layer is

defined

I (^) Compilers often define virtual machine layers: lambda

calculus, continuations, graph reduction, etc. in functional

languages, bytecode machines, etc

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

What is a compiler?

A compiler from language L 1 to language L 2 is a program that

takes an L 1 program and for each piece of code in L 1 generates a

piece of code in L 2 with the same meaning

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

What is an interpreter?

An interpreter of L 1 in L 2 is an L 2 program that executes the

meaning of a given L 1 program

Interpreters and compilers must know about both the syntax of the

language and its semantics, and must preserve the semantics (the

meaning)

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Mark Hills CS421 Lecture 1: Course Introduction

Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Compiler Front-End

I (^) Lex: Break the source into separate tokens

I (^) Parse: Analyze phrase structure and apply semantic actions,

usually to build an abstract syntax tree

I (^) Semantic analysis: Determine what each phrase means,

connect variable name to definition (typically with symbol

tables), check types

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Compiler Back-End

I (^) Translate to IR

I (^) Optimize: Improve generated code, while maintaining original

meaning

I (^) Instruction Selection

I (^) Register Allocation

I (^) Emit final code

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Sample IR

Source:

1 X = A + B + C;

Three Address Code:

1 %tmp.1 = A + B;

2 X = %tmp.1 + C;

Mark Hills CS421 Lecture 1: Course Introduction

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

Sample Optimization

Source:

1 while (X != 0) {

2 B = 5;

3 C = X + B;

4 X = ...

5 }

Target:

1 if (X != 0) B = 5;

2 while (X != 0) {

3 C = X + B;

4 X = ...

5 }

Outline Objectives for Today Administrivia Grading and Homeworks Motivation and History Language Design Language Implementation

Machine View Virtual View Compilation Interpretation Major Compiler Phases

For Further Information

I (^) For History, most books on languages. Sebesta Chapter 2 is

good, as well as Chapter 2 of Louden’s Programming

Languages: Principles and Practice. The books for the

History of Programming Languages workshops are good

in-depth sources as well. Finally, IEEE Annals of the History

of Computing has articles on this theme occasionally.

I (^) Language Design principles can be found in the same sources.

Obviously, there is disagreement about which features are

best, so it’s best to look at multiple sources.

I (^) For compilers, Compilers: Principles, Techniques, and Tools

by Aho, Sethi, and Ullman is the classic text. Cooper and

Torczon’s Engineering a Compiler is a more recent treatment.