Docsity

Course Overview - Data Structures and Functional Programming - Notes | CS 3110, Study notes of Computer Science

Partial preview of the text

Download Course Overview - Data Structures and Functional Programming - Notes | CS 3110 and more Study notes Computer Science in PDF only on Docsity!

CS 312 Lecture 1CS 312 Lecture 1 Course overview

Dan HuttenlocherCornell University Computer ScienceSpring 2009

Course staff „^ Prof. Dan Huttenlocher „^ Grad TAs:

„^ Office, consultingh

t d

b

‰^ Jean-Baptiste Jeannin ‰^ Ed McTigue „ UG Consultants:

hours posted on web

„^ UG Consultants:^ ‰

Andrew Owens ‰ Tanya Gupta

„^ Consulting Sun, Tue,Wed, Thu evenings

‰^ Rick Ducott ‰^ Dane Wallinga ‰^ David Kupiec

„^ Use TA, instructor

ffi^

h^

‰^ David Kupiec ‰^ Matt Pokryzwa ‰^ Jerzy HausknechtJ

b B

k

office hours!

‰^ J

acob Bank ‰^ Nyk Lotocky

Course meetings „^ Lectures Tues, Thurs: Phillips 219 „^ Recitations Monday Wednesday„^ Recitations Monday, Wednesday^ ‰

Upson 109, at 2:30pm ‰ Upson 109, at 3:35pm ‰ Possible third section – early evening?N^

i l i

d i

l

d

„^ N

ew material is presented in lecture

and

recitationAtt

d^

i^

t d

t l

t^

d^

it ti

„^ Att

endance is expected at lecture

and

recitation

„^ Participation counts

Course web site http://www.cs.cornell.edu/courses/cs

p

„^ Announcements „^ Lecture notesLecture

notes

„^ Assignments „^ Course software„^ Course software „^ OCaml documentationOther resources

„^ Other

resources

Readings „^ Course material in lecture notes onwebsitewebsite^ ‰

But you are also responsible for in-class material…

„^ Some other useful texts:„^ Some other useful texts:^ ‰

The Objective Caml System,

Leroy et al. (online)

‰^ Introduction to Objective Caml

Hickey (online)

‰^ Introduction

to Objective Caml

, Hickey. (online)

Assignments „^ 6 problem sets

–^

generally due Thursdays

„^6

problem sets – generally due Thursdays ‰ PS1 released Thursday, due Jan. 29: “OCaml Warmup” „^ Mix of programming, written problems „^ Submitted electronically via CMS^ ‰

24 hours late 10% penalty, 48 hours late 20% penalty „^ Four single-person assignments (1–4)

T^

k^

h

‰^ T

wo weeks each „^ Two two-person assignments (5–6)^ ‰

Three weeks each ‰^ Three

weeks each

Academic integrity „^ Strictly and carefully enforced^ ‰

Please don’t make us waste time on this‰ Please don t make us waste time on this ‰ Automated tools readily reveal code similarity even ifyou try to hide it by changing names, spacing, etc. ‰ Written problems also often surprisingly easy to see

„^ Start assignments early and get help from

t ff!

course staff! ‰^ Use the generous late policy if you can’t make thedeadline

dead

e

What this course is about Helping you become expert

designers and developers

of valuable software systems. 1) Programming

paradigms

2) Reasoningabout programs

3) Tools

paradigms New programming

about programs • Correctness

Data structuresand algorithms

p^

g^

g

language conceptsand constructs

  • Performance• Designing forreasoning and

and algorithms

reasoning andreuse

Programming any big system

1) Programming Paradigms „^ Functional programming „^ Polymorphism„^ Polymorphism „^ Pattern matching „^ Modular programming

beyond OO/classes

„^ Modular programming – beyond OO/classes „^ Concurrent programming – multi-core and UITypes and type inference„^ Types

and type inference

„^ Managed memory (garbage collection) „^ We’ll use ML to convey these concepts^ ‰

The important part are the concepts, not the ML syntax!

e^

po ta t pa t a e t e co cepts,

ot t e

sy ta

3) Data Structures & Algorithms „^ Standard structures: lists, trees, stacks,graphs, etc.graphs, etc.^ ‰

Functional versions of these structures

„^ More advanced structures:^ ‰

Balanced trees: AVL, Red-Black, B-trees, splay trees ‰ Disjoint sets ‰ Hash tables ‰ Binary heaps‰ Binary heaps

„^ A

lgorithms on these data structures

g

‰^ Analysis of correctness and performance

Imperative style „^ Program uses

commands

(a.k.a

statements

) that

do

things to the

state

of

statements

) that

do

things to the

state

of

the system: ‰^ x = x + 1;‰^ x = x + 1; ‰^ p.next = p.next.next; „ Functions/methods can have

side effects

i t^

h^

l (V hi l

) {^

i^

++

t^

}

‰^ i

nt wheels(Vehicle v) { v.size++; return v.numw; }

Functional style „^ Binding variables to values, not changing valuesof existing variables „^ No concept of

x=x+

or

x++

„^ Neither of these does anything remotely like

x++

let x = x+1 in xlet rec x = x+1 in x

„^ Former assumes an existing binding for

x^

and

creates a new one (no modification of

x ) latter is

creates

a new one (no modification of

x ), latter is

invalid expression

Trends against imperative style

Computer Program

Memory

„^ Fantasy:

program interacts with a single system state

‰^ Interactions are reads from and writes to variables or fields‰^ Interactions are reads from and writes to variables or fields. ‰^ Reads and writes are very fast ‰^ Side effects are instantly seen by all parts of a program „ Reality today:

there is no single state

„^ Reality

today:

there

is no single state

‰^ Multicores have own caches with inconsistent copies of state ‰^ Programs are spread across different cores and computers (PS5 & PS6) ‰^ Side effects in one thread may not be immediately visible in another ‰^ Side

effects in one thread may not be immediately visible in another ‰^ Imperative languages are a bad match to modern hardware and it’sonly getting worse