COMP 302: Lecture 1 Course Overview and Introduction to SML

advertisement
COMP 302: Lecture 1
Course Overview
and Introduction to SML
Joshua Dunfield
4 January 2010
McGill University
www.cs.mcgill.ca/∼joshua/302
1
Overview
• COMP 302: “Programming Languages and
Paradigms”
• . . . is not a trip to the zoo
• . . . is about thinking rigorously about
programming languages and programs
• What does a program do? How do you know?
What does it mean?
• How do you specify a programming language?
• [How do you implement a programming
language?]
2
Course Mechanics
• Prerequisites: COMP 250 or COMP 203
• If you have not taken either course,
talk to Liette Chin (Trottier 2070)
• We have TAs
• Your grade is 50% homework:
• 5 assignments, mixing programming and
written questions
• Midterm in class, worth 10%
• Final worth 40%
• You get two late days for homework
3
Textbook
• Robert Harper’s Programming in Standard ML
• Download it from the course website
• Also a version for printing 2-up
• You will not need to print the whole thing
4
Slide-Free Zone
• This may be the last lecture with slides
• Code and notes will be posted for many lectures
• You are responsible for what is presented in lecture
5
Don’t Copy Code
• It is possible to design exam questions that are
• moderately hard if you did the assignments
• very hard if you didn’t
• Copying is unfair to students who don’t
• Copying is likely to be noticed
• It’s against the rules
6
Don’t Copy Code
• If you’re worried that you will fail,
talk to us
• I would rather give some big hints in office hours
than have anyone copy code
7
Standard ML
• High-level, functional, and statically typed
• From the 1980s (revised 1997)
• No, it is not widely used in the “real” world
• Yes, you can get a job using functional languages
8
History
• PL/I was supposed to be huge
(“PL/I belongs more to the problem set than the
solution set” —E. Dijkstra)
• C++ was going to dominate forever
• Java appeared
Moral: No one knows what languages will be popular in
10, 20, 30 years.
9
Thinking on All Cylinders
• “The tools we use have a profound (and devious!)
influence on our thinking habits, and, therefore, on
our thinking abilities.” —E. Dijkstra
• There is no more important tool when
programming
• Even in Java or C++, it can be useful to “think in”
another language
10
Values and Effects
• SML is (primarily) a functional language
• Evaluation, not execution
• Values, not effects
• Binding, not assignment
11
Types
• SML is statically typed
• Types describe data:
integers, strings, lists of strings,
lists of pairs of strings and integers,
vectors, arrays. . .
12
Types
• SML is statically typed
• Types describe data:
integers, strings, lists of strings,
lists of pairs of strings and integers,
vectors, arrays. . .
• Types describe the behaviour of functions:
integers to integers, strings to integers,
lists of things to lists of lists of things. . .
12
Types
• SML is statically typed
• Types describe data:
integers, strings, lists of strings,
lists of pairs of strings and integers,
vectors, arrays. . .
• Types describe the behaviour of functions:
integers to integers, strings to integers,
lists of things to lists of lists of things. . .
• Types are checked by the compiler
• You’ll need to write types sometimes,
but SML will often figure them out
12
Demo
[SML demo—basicSML.sml]
13
First Assignment
• Basic SML programming with lists and trees
• Out Wednesday, Jan. 6 (we hope)
• Due Wednesday, Jan. 20
14
Zeroth “Assignment”
• Get a CS account (if you don’t have one)
• Get access to the SML of New Jersey compiler:
www.cs.mcgill.ca/~joshua/302/faq.php
• Start reading Harper, chapter 2
15
Download