510 likes | 523 Views
The Structure and Interpretation of the Computer Science Curriculum. Matthias Felleisen Northeastern University. SICP - We believe …. It’s a fantastic book. It has flaws. Let’s improve it. SICP was Great for the FP Community. Exposure to functional concepts complex, structured data
E N D
The Structure and Interpretation of the Computer Science Curriculum Matthias Felleisen Northeastern University
SICP - We believe … It’s a fantastic book. It has flaws. Let’s improve it.
SICP was Great for the FP Community • Exposure to functional concepts • complex, structured data • higher-order functions • streams • Exposure to Scheme, a (mostly) functional language
SICP was great for CS1 Community • It destroyed the tyranny of syntax in CS1. • It showed the world that CS is an intellectually deep field. • It liberated CS1 from fashion …
So what happened? • … or did it? • Why did the use of Scheme decline so rapidly? Why wasn’t it replaced by FPLs? • Why did SICP courses go away everywhere?
Why did SICP fail? Was SICP just fashionable for a while? Is it the victim of the fashion-obsession in CS? Especially CS1? Was SICP flawed? Did it fail CS departments in other ways? Why does this matter?
SICP: the Milestone • SICP is a milestone in international CS1 history … every decent CS1 author must justify a new book with a critique • If SICP failed, the F/D community must understand its problems and try to overcome them. Otherwise, we repeat history and lose.
HtDP and DrScheme HtDP is a new text book. It uses Scheme. It is for CS1. Ergo, it needs a design rationale and a comparison to SICP. This paper is it.
Introductory Programming and Computing • Sociological constraints • Timing constraints • Content constraints
Introductory Programming and Computing Parents: “Newsweek writes about Java a lot. Why are they teaching my son Scheme? Student: “I know everything, and I know that Cobol is it!” CS 1 Introduction to Programming and Computing Industry: “Today we’re using C# v4.538. How come you’re not teaching that?” Colleague: “Everything in my world needs pointers. They better learn that in CS1.”
Introductory Programming and Computing students who can program in some PL at similar skill level CS 1 Introduction to Programming and Computing students w/o any background students who “program” students with math. bg
Introductory Programming and Computing the first summer life Timing Constraints: Students need something practial at those points.
Introductory Computing and Programming • CS1 cannot satisfy all constraints • We must pick those that are compatible with a university’s promise to its students. • We must help instructors to develop the spine to stand up for the goals they adopt.
Introductory Computing and Programming Thesis 1: The University’s goal is to produce effective software developers who can quickly adapt to current practice and who can survive in a software related profession for decades.
Introductory Computing and Programming Thesis 2: A University’s CS curriculum should concentrate on principles for most of the time but it should accommodate “industrial” needs during the second semester and the fourth (last) year.
Introductory Computing and Programming Thesis 3: The first year should start with an emphasis on principles and should then migrate to something that students can use in a first summer internship.
Principles for the First Course • the first course does not exist in a vacuum; it must prepare for the second course • the second course should, and will, teach some form of class-based, object-oriented programming
Principles for the First Course • What do we teach in the first course in Scheme (or some other F/D language) so that students like it and so that they are prepared for the second course? • What’s the strength of F/D in this context?
Principles for the First Course • Students must learn to read problem statements. • Their reading must help them produce: • a description of the classes of data that matter • a concise purpose statement for the program
Principles for the First Course • Students must illustrate abstract statements with • concrete examples, in particular, they must have • their classes of data • their purpose statement
Principles for the First Course Students must be able to create a program organization based on their data descriptions. In an FP world, this usually means using an algebraic datatype. In an OOP world, this translate to a class hierarchy.
Principles for the First Course Students must check their facts. That is, they must learn to test their programs and test them automatically.
Principles for the First Course • FP helps because it is value-oriented. It naturally separates reasoning about classes from other OOP ideology. • Reasoning about classes of values and exploiting this reasoning for the systematic construction of programs is what FP is best at.
Scheme is the best • No, it is NOT the Scheme from SICP. • Scheme, like any other language, is unsuitable for a first course. • But, Scheme has a number of advantages that we can exploit. • See our other publications on this topic.
SICP’s Failures: Professionals’ Views Jackson and Chapin, MIT: from an educational point of view, our experience suggests that undergraduate computer science courses should emphasize basic notions of modularity, specification, and data abstraction, and should not let these be displaced by more advanced topics, such as design patterns, object-oriented methods, concurrency, functional languages, and so on. They are primary SICP consumers.
SICP’s Failures: Students’ Views “A few years ago, I was trying to hire MIT students as undergraduate research assistants, and I asked one undergrad why it seemed that most all MIT students wanted to code in Java and have nothing to do with Scheme after they passed 6.001 (the SICP course). He felt that students were turned off by a combination of the tools and the nature of the assignments. The default Scheme implementation, he claimed was painfully slow. … He also said something about students associating Scheme with unpleasant problem sets in what is understandably a challenging first-year course.
SICP’s Failures: Students’ Views “… Some time later, when I asked him why MIT Scheme says "Happy Happy Joy Joy" when you exit, he said that was because exiting meant that your problem sets were done. ------------------------------------------------------------------ 1 ]=> (exit) Kill Scheme (y or n)? Yes Happy Happy Joy Joy. ------------------------------------------------------------------
SICP’s Coverage functional progr. higher-order progr. data abstraction impl. objects stream-based progr. modules logic progr. primality interval arithmetic symb. differentiation representing sets digital circuits interpreters register machines, compilers Programming: Content Domain:
SICP and Programming Knowledge • examples, examples, examples • exercises: • modify existing code • solve a very similar, related problem • students, now do it on your own Students must learn implicitly. SICP does not contain explicit program design knowledge.
SICP Domain Knowledge • SICP covers two domains: • mathematical problems, with an EE flavor • meta-problems (problems about Computing) SICP fails to cover a broad range of “application flavored” problems.
SICP in Summary • Whereas SICP covers a range of interesting programming techniques, and • whereas SICP covers a range of interesting math. problem domains, • SICP fails to state program design knowledge and • SICP does not hook students on FP. NOT SUITABLE FOR A FIRST COURSE
HtDP’s Starting Point • State design principles explicitly. • Make sure design principles scale to OO. • Use simple domain knowledge that doesn’t distract from program design. • Develop supplements that illustrate design in practial and interesting context.
HtDP’s Design Recipes • problem analysis & data definition • contract, purpose statement, function header • examples of data, behavioral examples • function template • function body • tests
HtDP: Data Definitions and OOP Dog name : String age : Number neutered : Boolean type Dog = struct{name:String, age:Number, neutered:Boolean}
HtDP: Data Definitions and OOP Circle Posn radius : Number center : Posn color : String x : Number y : Number type Posn = struct{x:Number, y:Number} type Circle = struct{radius:Number, center:Posn, color:String} containment (has-a)
HtDP: Data Definitions and OOP type Shape = Circle of … | Square of … | Line of … | … Shape Circle Square Line superclasses (is-a)
HtDP: Data Definitions and OOP type Shape = Circle of … | Square of … | Union of Shape * Shape Shape Circle Square Union recursive data descriptions (mixing has-a/is-a)
HtDP: Data Definitions and OOP type Shape = Circle of … | Square of … | Union of ShapeList and ShapeList = empty | cons of Shape * ShapeList Shape ShapeL mutual references
HtDP: Data Definitions and OOP fun f_and_g(delta1, delta2) = fn s => … functional abs. fun f(s) = … fun g(s) = … f() { … } template and hook f() { … } g() { … }
HtDP: Other Ideas • generative vs structural recursion -- or how insertion sort really differs from quicksort • accumulator-style functions don’t have to be tail recursive; they do accumulate • effects are orthogonal to the game; a disciplined story
HtDP: Domain Knowledge • pairs, teachpacks, and partners • simple games • simple graphics • simple Web interactions • and more to come
Conclusions • The first course can, and ought to, teach principles. • The first course must prepare the second course. • The second course is, and will be, OOP.
Conclusions • FP is great for the first course, because it helps students learn to reason about values and classes of values. • From class descriptions it is a short step to a schematic program organization that anticipates OO class hierarchies in the second course.
Conclusions • HtDP is our attempt to turn this idea into reality. • It emphasizes program design knowledge. • It comes with a supportive PDE. • Soon, it will integrate exercises that are easy in FP and yet are extremely concrete and applied.