39
A Scheme A Scheme Workshop Workshop Ben Leong Ben Leong NUS School of Computing NUS School of Computing 28 July 2008 28 July 2008

A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Embed Size (px)

Citation preview

Page 1: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

A Scheme WorkshopA Scheme Workshop

Ben LeongBen LeongNUS School of ComputingNUS School of Computing

28 July 200828 July 2008

Page 2: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Welcome to SoCWelcome to SoC

Help you make an informed Help you make an informed decision on whether to choose decision on whether to choose between CS1101 and CS1101Sbetween CS1101 and CS1101S

NOTNOT to teach you Scheme to teach you Scheme About which class is About which class is more more

suitablesuitable for for YOUYOU

NOTNOT about which is better…. about which is better….

Page 3: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

OverviewOverview

What’s Scheme?What’s Scheme? Why Scheme?Why Scheme? Module SynopsisModule Synopsis

(i.e. what to expect)(i.e. what to expect) What your seniors sayWhat your seniors say

Page 4: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Brief History of CS1101SBrief History of CS1101SThe language Scheme was designed 27 The language Scheme was designed 27

years ago at MIT to teach programming years ago at MIT to teach programming methodologymethodology

The success of the MIT programming The success of the MIT programming methodology module led to its adoption in methodology module led to its adoption in many universities worldwidemany universities worldwide

Scheme was first introduced at NUS Scheme was first introduced at NUS 1111 years agoyears ago

I took this class at MIT in I took this class at MIT in 19941994. .

Page 5: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

ObjectivesObjectives

Teach Scheme as a programming language Teach Scheme as a programming language

Teach programming conceptsTeach programming concepts Inspire CONFIDENCE in students that Inspire CONFIDENCE in students that

ANYTHING can be solved if they try hard ANYTHING can be solved if they try hard enoughenough

Teach students Teach students

Computational ThinkingComputational Thinking

TO THINK TO THINK

NOT!NOT!

Page 6: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Introduction to SchemeIntroduction to Scheme

Scheme is expression oriented. Type an Scheme is expression oriented. Type an expression and its result will be printed expression and its result will be printed out.out.

Works with a variety of types of numbers: Works with a variety of types of numbers: integers (both positive and negative), integers (both positive and negative), fractions (rational numbers), and real fractions (rational numbers), and real numbersnumbers

Page 7: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Introduction to SchemeIntroduction to Scheme

Expressions use prefix notation.Expressions use prefix notation.Use Use (+ 2 3)(+ 2 3) instead of instead of (2 + 3)(2 + 3)Use Use (* (+ 2 3) (- 3 1))(* (+ 2 3) (- 3 1)) instead of instead of (2+3)*(3-1)(2+3)*(3-1)

There is a wealth of predefined There is a wealth of predefined functionsfunctionssqrtsqrt computes the square root of its computes the square root of its

argument.argument.+ + is also a predefined functionis also a predefined function

Page 8: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Why Scheme?Why Scheme?

Teaching a language is futileTeaching a language is futile(Here today, gone tomorrow)(Here today, gone tomorrow)

Scheme is simple as a languageScheme is simple as a languageSo we can focus on the So we can focus on the

CONCEPTSCONCEPTS instead of instead of clunky clunky language ruleslanguage rules

Let’s see for ourselves…..Let’s see for ourselves…..

Page 9: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Key Concept: RecursionKey Concept: Recursion

Express (divide) a problem into Express (divide) a problem into smaller similar problemssmaller similar problems

Solve the problem for a simple Solve the problem for a simple (base) case(base) case

We are done (!)We are done (!)Similar to Similar to

Mathematical InductionMathematical Induction

Page 10: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

The Towers of HanoiThe Towers of HanoiWe have 3 pegs and a set of discs, all of different diameters.

Objective: move the pile of discs to last peg, by: moving 1 disc at a time from 1 peg to another; never placing a disk on top of another disc with

smaller diameter.

Suppose you have not 3, but Suppose you have not 3, but nn discs … discs …

Page 11: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

The Towers of HanoiThe Towers of Hanoi

We must start somewhere….Suppose we have one disc ….What if there are no discs?

Nothing to do!Base case

Page 12: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

The Towers of HanoiThe Towers of Hanoi

We notice the following pattern: if we want to move n disks from peg a to peg c using peg b as intermediary storage, then we:assume we know how to move n−1 disks to peg

b, using peg c as intermediary storage;we move disk n from a to c ;we move n−1 disks from b to c, using a as

intermediary storage.

RECURSIONRECURSION

Page 13: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

The Towers of HanoiThe Towers of Hanoi

(define (move-tower size from to extra)

(cond ((= size 0) #t)

(else

(move-tower (- size 1) from extra to)

(print-move from to)

(move-tower (- size 1) extra to from))))

(define (print-move from to)

(newline)

(display "move top disk from ")

(display from)

(display " to ")

(display to))

Page 14: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

DEMODEMO

Page 15: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

CS1101S: Programming CS1101S: Programming Methodology Methodology (Scheme)(Scheme)

Lectures: Lectures: Wed 10am-12pm, Fri 11am-12pm, LT15Wed 10am-12pm, Fri 11am-12pm, LT15Recorded for webcastRecorded for webcast

Recitations: 1 hr/wkRecitations: 1 hr/wkTwo or three groups: Prob Thurs, Venue Two or three groups: Prob Thurs, Venue

TBATBADiscussion Groups: 2 hr/wkDiscussion Groups: 2 hr/wk

Three or four groups: TBAThree or four groups: TBABid for group in CORSBid for group in CORS

Page 16: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Teaching StaffTeaching Staff

Lecturer: Dr. Ben Leong, Lecturer: Dr. Ben Leong, [email protected]@comp.nus.edu.sgOffice: S14 #06-14Office: S14 #06-14Phone: 6516-4240Phone: 6516-4240Hours: TBA, or by appointmentHours: TBA, or by appointment

Teaching Assistant: Chu Duc HiepTeaching Assistant: Chu Duc Hiep EIGHTEIGHT Undergraduate Discussion Undergraduate Discussion

Group LeadersGroup Leaders

Page 17: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Syllabus (in Brief)Syllabus (in Brief) Numeric computations in Scheme Building recipes with functions Recursion Data structures: lists, trees Memoization & Dynamic Programming Generic operations Object oriented abstractions Java

Covers core concepts of computer Covers core concepts of computer programmingprogramming

Page 18: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Textbook : Textbook : SICPSICP

FREE!!FREE!! Available online at Available online at

http://mitpress.mit.edu/sicp/full-http://mitpress.mit.edu/sicp/full-text/book/book.htmltext/book/book.html

Page 19: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Supplementary Supplementary TextText

ALSO FREE!!ALSO FREE!! Available online at Available online at

http://gustavus.edu/+max/conchttp://gustavus.edu/+max/concrete-abstractions-pdfs/index.htrete-abstractions-pdfs/index.htmlml

Page 20: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Supplementary Supplementary Reference 2Reference 2

ALSO FREE!!ALSO FREE!! Available online at Available online at

http://www.htdp.org/http://www.htdp.org/

Page 21: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Scheme InterpreterScheme Interpreter

We will be using DrSchemeWe will be using DrScheme It’s FREE!!!It’s FREE!!!Download from:Download from:

http://www.drscheme.org/http://www.drscheme.org/

Page 22: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Assessment OverviewAssessment Overview

Tutorial participation: Tutorial participation: 10%10%Problem sets: Problem sets: 30%30%Midterm exam: Midterm exam: 15%15%

1 Oct 2008 (Wed) 10am-12 pm1 Oct 2008 (Wed) 10am-12 pmPractical exam:Practical exam: 15%15%

5 Nov 2008 (Wed) 10am-12 pm5 Nov 2008 (Wed) 10am-12 pm

Final exam: Final exam: 30%30%

1 Dec 2008 (Mon) 9 am 1 Dec 2008 (Mon) 9 am

Page 23: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Tutorial Participation (10%)Tutorial Participation (10%)

Questions will usually be given out prior to Questions will usually be given out prior to the recitations/discussion groups, the recitations/discussion groups, sometimes notsometimes not

Assessed mainly by tutors, with some inputs Assessed mainly by tutors, with some inputs from lecturer from interactions during from lecturer from interactions during recitations & lecturesrecitations & lectures

You need to be active, participate by You need to be active, participate by offering solutions, making comments and offering solutions, making comments and asking questions.asking questions.

Page 24: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Midterm and Final ExamsMidterm and Final Exams (15% + 30%) (15% + 30%)

Standard fare – 2 hours eachStandard fare – 2 hours eachWill test concepts, Will test concepts, NOTNOT memory memoryOpen-sheet Open-sheet

1 x A4 sheet of notes allowed for midterm1 x A4 sheet of notes allowed for midterm2 x A4 sheet of notes allowed for finals2 x A4 sheet of notes allowed for finals

Sample midterms and finals available in Sample midterms and finals available in IVLE IVLE

Page 25: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Problem Sets (30%)Problem Sets (30%)

Seven problem setsSeven problem setsDue approximately once every two Due approximately once every two

weeksweeksGraded by the Undergraduate Tutors Graded by the Undergraduate Tutors Crucial for learning the material in this Crucial for learning the material in this

classclassThis is effectively the lab component of This is effectively the lab component of

the classthe class

Page 26: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Practical Exam (15%)Practical Exam (15%)

““Test of the Pudding”Test of the Pudding”

At the completion of Scheme At the completion of Scheme syllabussyllabus

2 hours to solve three programming 2 hours to solve three programming problems of increasing difficultyproblems of increasing difficulty

Sample exams available on IVLESample exams available on IVLE

Page 27: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Other HighlightsOther Highlights

Will build a Lego Mindstorm robot in the Will build a Lego Mindstorm robot in the middle of the Semestermiddle of the Semester

Regular Programming Contests to keep Regular Programming Contests to keep students challengedstudents challenged

Page 28: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

CS1101S Robot ContestCS1101S Robot Contest

Page 29: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

CS1101S Robot ContestCS1101S Robot Contest

See more at See more at CS1101S CS1101S FacebookFacebook Group Group

Page 30: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

CS1101S vs. CS1101CS1101S vs. CS1101

Progression: CS1101S Progression: CS1101S CS1102S CS1102S CS1101 CS1101 CS1102 CS1102

Two-semester sequenceTwo-semester sequenceDiscouraged from crossing overDiscouraged from crossing overCS1101S CS1101S CS1102, CS1101 CS1102, CS1101 CS1102S CS1102S

SimilaritiesSimilaritiesS and non-S versions both teach basic S and non-S versions both teach basic

programming principlesprogramming principles

Page 31: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

CS1101S/02S vs. CS1101/02CS1101S/02S vs. CS1101/02

DifferencesDifferencesCS1101S/02S cover more advanced CS1101S/02S cover more advanced

topicstopicsMore challengingMore challengingCS1102S covers Java + moreCS1102S covers Java + moreGood introduction to many computer Good introduction to many computer

science topicsscience topics

Page 32: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Which to take?Which to take?Take CS1101S/02S if you want to be Take CS1101S/02S if you want to be

challenged.challenged. If you have programmed beforeIf you have programmed before

No real advantageNo real advantage In fact, can be a disadvantage!In fact, can be a disadvantage!

If you have never programmed beforeIf you have never programmed beforeGreat! You are not at a disadvantage.Great! You are not at a disadvantage.Keep an open mind.Keep an open mind.

If CS is not your first choice course, If CS is not your first choice course, CS1101S is probably CS1101S is probably NOTNOT a good choice. a good choice.

Page 33: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Java vs Scheme: Java vs Scheme: What’s the Tradeoff?What’s the Tradeoff?

Java: sophisticated, mature can be used for commercial applications but has many underlying concepts that a beginner

may find hard to understand

Scheme: simple, elegant easy to learn (hard to master) designed to illustrate the concepts BUT you will eventually learn Java anyway….

Mainly a question of personal choice (taste?)

Page 34: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

What your seniors say….What your seniors say….

I think Scheme really does bring about concepts easily. I think Scheme really does bring about concepts easily. Java's messy, so messy for an amateur programmer. Java's messy, so messy for an amateur programmer.

(on Problem Sets) They are all very difficult, but some are (on Problem Sets) They are all very difficult, but some are killers. killers.

I learnt a tiny bit of java before I attended this class and I I learnt a tiny bit of java before I attended this class and I was totally lost. Teaching introduction to programming in was totally lost. Teaching introduction to programming in Scheme is a quite smart idea. I feel much better when I Scheme is a quite smart idea. I feel much better when I came back to Java at the end of this class. came back to Java at the end of this class.

[What doesn’t kill you makes you strong][What doesn’t kill you makes you strong]

Page 35: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

What your seniors say….What your seniors say….

I was warned by my seniors not to take scheme I was warned by my seniors not to take scheme because they said it was very tough .... now when because they said it was very tough .... now when I’ve done this module , I agree that it is tough.. but I’ve done this module , I agree that it is tough.. but it is worth the effort ..scheme makes u it is worth the effort ..scheme makes u smarter !!! :) smarter !!! :)

Do you agree that Scheme is easier than Java? Do you agree that Scheme is easier than Java? 32% NO; 68% YES! 32% NO; 68% YES!

The pace might be fast but if a person is able to The pace might be fast but if a person is able to handle it I think they would definitely benefit from handle it I think they would definitely benefit from it and enjoy it more than CS1101XYZ it and enjoy it more than CS1101XYZ

Page 36: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

More comments here ….More comments here ….http://www.comp.nus.edu.sg/~bleong/teahttp://www.comp.nus.edu.sg/~bleong/tea

ching/cs1101s06-midterm.htmching/cs1101s06-midterm.htmhttp://www.comp.nus.edu.sg/~bleong/teahttp://www.comp.nus.edu.sg/~bleong/tea

ching/cs1101s06-final.htmching/cs1101s06-final.htmhttp://www.comp.nus.edu.sg/~bleong/teahttp://www.comp.nus.edu.sg/~bleong/tea

ching/cs1101s07-midterm.htmching/cs1101s07-midterm.htm

Just Google “Just Google “cs1101s survey”!!!cs1101s survey”!!!

Page 37: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

Words of AdviceWords of Advice

Don’t worry about the curveDon’t worry about the curveScheme is easier (than Java or so I Scheme is easier (than Java or so I

would claim), but doesn’t mean that would claim), but doesn’t mean that CS1101S is an easier classCS1101S is an easier class

Take CS1101S still have to learn Take CS1101S still have to learn Java…. so it is definitely more work Java…. so it is definitely more work

Have to be prepared to work Have to be prepared to work veryvery hard hard in CS1101Sin CS1101S

Page 38: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

QUESTIONSQUESTIONS

Page 39: A Scheme Workshop Ben Leong NUS School of Computing 28 July 2008

THANKTHANKYOUYOU