385x Filetype PDF File size 0.40 MB Source: www.cs.utexas.edu
What is this course about?
CS345H: Programming Languages ◮ This course is about programming languages
Lecture 1: Introduction and Lambda Calculus I ◮ We will study different ways of specifying programs
◮ We will learn how to give (precise) meaning to programs
Thomas Dillig
◮ We will see how to use programming languages to prevent
run-time errors
◮ We will explore these concepts in real-world languages
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 1/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 2/36
Why should you take this course? Course Administration
◮ Understanding programming languages means that you will be ◮ (Tentative) syllabus is on class website at
able to program in any existing or future programming cs.utexas.edu/˜tdillig/cs345h
language almost immediately ◮
Instructor: Prof. Thomas Dillig
◮ You will be able to choose the right language for the right
problem ◮ TAs: Pengxiang Cheng
◮ You will have techniques to give precise semantics to any ◮ Office hours: See course website for updates
string, not just programs. ◮
Wealso use Piazza
◮ You will have a much easier time getting (and keeping) jobs ;-) ◮
Check this website and Piazza!
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 3/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 4/36
Course Administration Course Administration - Dates
This class has the following requirements:
◮ You will build an interpreter for a realistic language. The following exams are scheduled:
◮ Midterm 1: 10/11 in class
◮ Substantial project, but broken up into 4 manageable
programming assignments ◮ Midterm 2: 11/15 in class
◮ One larger, open-ended project ◮ Final: 12/11 in class
◮ We will have approx. weekly written homeworks ◮ You must be available at these dates, no alternate exams.
◮ Two in-class midterms and final during finals week. ◮ If you miss an exam, your score is 0.
◮ This is a difficult class with a substantial workload
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 5/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 6/36
1
Grading Grading
◮ Grades breakdown
◮ 15%: each midterm
◮ The final grades will be curved
◮ 25% Final
◮ 20% Written Assignments ◮ However: Your grade will never get worse from curving, only
better
◮ 25% Programming Assignments
◮ You will receive lots of feedback through assignments and
◮ Each written assignment is due at the beginning of class, each midterms
programming assignment at midnight on the due date. ◮
Wewill post average and standard deviations on all scores, so
◮ You have 3 24-hour period late days to use, but you cannot you know how you are doing
use more than 2 late days on one assignment.
◮ Anything handed in after this will receive 0 credit.
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 7/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 8/36
Getting Help Collaboration
◮ You must complete the written assignments individually
◮ Wewill use the newsgroup function in Piazza for any questions ◮ If you discuss the assignment with other students, you must
about homework, programming assignments and material. acknowledge their names on your assignment
◮ We will not answer any emails about these topics ◮ You may complete the programming assignments alone or in
pairs; you can change your parter on each project, but not
◮ For any personal issues reach out directly to me via email. during one project
◮ We use plagiarism-detection software to ensure your programs
are not copied. Any cheating will result in an F for the course
and referral to the UT honor code violation committee
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 9/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 10/36
Other Policies Let’s get started!
Some comments:
◮ No makeup anything to improve grades
◮ Grades are final, I will never change the course grade after the
semester
◮ It is your responsibility to check for grading mistakes on
Canvas when assignments are handed back. If we don’t hear
from you within a week, your score is final
◮ You are responsible for anything announced in class
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 11/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 12/36
2
History of Programming Languages History of Programming Languages
◮ It all started in 1954, with the IBM 704 computer
◮ This computer was programmed with assembly instructions
written on punch cards
◮ Problem: For the first time in IBM’s history, software
development costs exceeded hardware cost!
◮ Solution proposed: Program computer in a higher-level
language than assembly
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 13/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 14/36
FORTRAN I Impact of FORTRAN
◮ Enter John Backus ◮ Within 2 years: 80% of programs written for the IBM 704
◮ were written in FORTRAN
Translation from higher-level
language to assembly had already ◮ This is even though FORTRAN I is a pretty awful language
been tried before... (by today’s standards)
◮ And did not work out (at all) ◮ After this: Almost all programming done in (increasingly)
◮ higher level languages
But team lead by John Backus
produced first practical ◮ Programming languages have greatly improved programmer
programming language called productivity, enabling software that would never haver been
FORTRAN and a compiler to possible otherwise
translate it to assembly
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 15/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 16/36
Language Goals: Language Evolution
◮ In the beginning, overarching concern when developing
languages was performance
◮ As hardware got faster, many different goals emerged:
Reliability, Security, Ease of Use, Re-usability, etc
◮ This resulted in thousands of actual programming languages
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 17/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 18/36
3
Language Design Today Lambda Calculus
◮ There are many programming languages we could talk about
◮ We understand pretty well how to design good programming
languages ◮ But pretty much all real languages are complex, large and
obscure many important issues in irrelevant details
◮ However, many bad languages are still designed
◮ We want: ”as simple as possible”language to study properties
◮ After this class, you will be able to recognize bad of programming languages
programming languages
◮ This language is known as lambda calculus
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 19/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 20/36
Lambda Calculus Lambda Calculus Syntax
◮ There are only four expressions in lambda calcus: ◮ Or, more concisely, the syntax of a lambda calculus expression
◮ Expression 1: constants as context-free grammar is given by:
◮ 1, 7, ”yourName”are all valid expressions in lambda calculus e = c | id | λid.e | e e
1 2
◮ Expression 2: identifiers ◮ This is a production that defines the left hand side (here an
◮ Will usually use x, y, etc for those expression e)
◮ Expression 3: lambda abstraction ◮ Observe that this production is recursive
◮ written as λx.e
◮ Expression 4: application ◮ With this production, we can now check if any expression is
◮ written as e e valid lambda calculus
1 2
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 21/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 22/36
Lambda Calculus Syntax Are we done?
◮ Consider the expression: A = (λx.x) 3 ◮ We can now decide if any string is lambda calculus
◮ Now, recalling the syntax ◮ But we have no idea (yet) what these expressions mean!
e = c | id | λid.e | e e
1 2 ◮ Just because we defined a syntax, this does not mean we have
we can give a derivation proving that A is valid given meaning to expressions
◮ e →e e →e 3→(λx.e) 3→(λx.x) 3 ◮ Giving meaning to syntax is called semantics
1 2 1
◮ Any expression for which we can find a derivation is ◮ Big chunk of this class: How to define syntax and semantics
syntactically valid lambda calculus of programming languages
Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 23/36 Thomas Dillig, CS345H: Programming Languages Lecture 1: Introduction and Lambda Calculus I 24/36
4
no reviews yet
Please Login to review.