Download Data Structures & Functional Programming: A Comprehensive Course Overview and more Schemes and Mind Maps Data Structures and Algorithms in PDF only on Docsity!
http://www.flickr.com/photos/rofi/2097239111/
Data Structures and
Functional Programming
Course Overview
Nate Foster
Cornell University
Spring 2012
Course staff
Instructor: Nate Foster
- Joined Cornell last year from UPenn
- Research area: programming languages
- Functional programmer since 1998
TAs: Shrutarshi Basu (coordinator), Ashir Amer,
Stuart Davis, Gautam Kamath, Katie Meusling,
Greg Zecchinni
Consultants: many
You have a large and veteran staff. Make use of them!
Office hours in Upson 360 Sunday-Thursday from 7-9pm
Additional office hours Thursday from 5-7pm
Course web site
http://www.cs.cornell.edu/Courses/cs
- Course material
- Homework
- Announcements Includes a complete set of course notes Nearest equivalent to a textbook But the lectures and sections are definitive Links to lecture notes will go live shortly after lecture Goal is to help, not replace attendance!
Piazza and CMS
Online discussion forum Monitored by TAs/consultants Ask for help, but don’t post solutions CMS “Course Management System” Built by Andrew Myers (with help from lots of students) Assignments and grades posted here
Grading
Breakdown:
- 45% - Problem sets
- 5% - Quizzes (lowest dropped)
- 30% - Preliminary exams (lower exam weighted less)
- 20% - Final exam Will follow the usual CS3110 curve
- Centered around a B/B+
Late policy
You can hand it in until we start grading
- 15% penalty / day
- After we start grading, no credit Save your code and submit early and often
- CMS is your friend
- Be certain you have submitted something, even if it isn’t perfect and you are improving it
If you have a emergency (e.g., medical, family) talk to
Nate before the last second
What this course is about
Programming isn’t hard Programming well is very hard
- Programmers vary greatly
- 10X or more difference in skills We want you to write code that is:
- Reliable, efficient, readable, testable, provable, maintainable… beautiful! Expand your problem-solving skills
- Recognize problems and map them onto the right abstractions and algorithms
Thinking versus typing
“A year at the lab bench saves an hour at the library” Fact: there are an infinite number of incorrect programs Corollary: making random tweaks to your code is unlikely to help
- If you find yourself changing “<“ to “<=“ in the hopes that your code will work, you’re in trouble Lesson: think before you type! http://www.flickr.com/photos/tmartin/32010732/
Rule
Good programmers are lazy
- Never write the same code twice (why?)
- Reuse libraries (why?)
- Keep interfaces small and simple (why?) Pick a language that makes it easy to write the code you need
- Early emphasis on speed is a disaster (why?) Rapid prototyping!
Main goal of CS
Master key linguistic abstractions:
- Procedural abstraction
- Control: iteration, recursion, pattern matching, laziness, exceptions, events
- Encapsulation: closures, ADTs
- Parameterization: higher-order procedures, modules Mostly in service to rule # Transcends individual programming languages
Choice of language
This matters less than you suspect Must be able to learn new languages
- This is relatively easy if you understand programming models and paradigms We will be using OCaml, a dialect of ML Why use yet another language?
- Not to mention an obscure one? Main answer: OCaml programs are easy to reason about
Why?
Awesome OCaml feature: many common errors simply impossible More precisely, they are caught at compile time Early failure is very important (why?) Functional language Programs have a clear semantics Heavy use of recursion Lots of higher-order functions Few side effects Statically typed and type safe Many bugs caught by compiler
Functional Style
Idea: program without side effects
- Effect of a function is only to return a result value Program is an expression that can be evaluated to produce a value
- For example, evaluating 2+2 yields 4
- Just like mathematical expressions Enables equational reasoning about programs:
- if x equals y, replacing y with x has no effect:
- let x=f(0) in x+x equivalent to f(0)+f(0)
Functional Style
Bind variables to values, don’t mutate existing variables No concept of x=x+1 or x++ These do nothing remotely like x++ let x = x+1 in x let rec x = x+1 in x The former assumes an existing binding for x and creates a new one (no modification of x ) The latter is an invalid expression