TeachScheme, ReachJava Stephen Bloch, Adelphi University, Garden City, NY John Clements, Cal Poly, San Luis Obispo, CA Kathi Fisler, Worcester Polytechnic.

Slides:



Advertisements
Similar presentations
The TeachScheme! Project Adelphi University Brown University Northeastern University University of Chicago University of Utah Worcester Polytechnic Institute.
Advertisements

Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
CS 206 Introduction to Computer Science II 01 / 20 / 2009 Instructor: Michael Eckmann.
Racket Introduction CSC270 Pepper major portions credited to
2-May-15 GUI Design. 2 HMI design There are entire college courses taught on HMI (Human-Machine Interface) design This is just a very brief presentation.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Chapter Day 5. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 Posted  Introduction on developing.
CSC 160 Computer Programming for Non-Majors Lecture #8: Animations I Prof. Adam M. Wittenstein
Lisp. Versions of LISP Lisp is an old language with many variants –LISP is an acronym for List Processing language Lisp is alive and well today Most modern.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
CS 201 Functions Debzani Deb.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
Introducing Java.
TeachScheme, ReachJava Adelphi University Monday afternoon July 12, 2010.
TeachScheme, ReachJava Adelphi University Tuesday morning July 13, 2010.
Methods (Functions) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Java: Chapter 1 Computer Systems Computer Programming II.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.
Invitation to Computer Science, Java Version, Second Edition.
TeachScheme, ReachJava Adelphi University Tuesday afternoon July 13, 2010.
COSC 1P02 Introduction to Computer Science 3.1 Cosc 1P02 Week 3 Lecture slides Birthdays are good for you. Statistics show that the people who have the.
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Python programming Introduction to the JES environment and basics of Python Reading: Chapters 1, 2 from “Introduction to Computing and Programming in Python”
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/6/08.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
Problem of the Day  Why are manhole covers round?
Summer Computing Workshop. Introduction  Boolean Expressions – In programming, a Boolean expression is an expression that is either true or false. In.
CS 330 Programming Languages 11 / 13 / 2008 Instructor: Michael Eckmann.
PowerPoint Basics Tutorial 1: Objects These tutorials will introduce you to the most basic and useful functions of Microsoft PowerPoint We’re going.
XP Tutorial 8 Adding Interactivity with ActionScript.
TeachScheme, ReachJava Stephen Bloch, Adelphi University, Garden City, NY John Clements, Cal Poly, San Luis Obispo, CA Kathi Fisler, Worcester Polytechnic.
TeachScheme, ReachJava Adelphi University Friday morning July 16, 2010.
CS305j Introduction to Computing Classes 1 Topic 23 Classes – Part I "A 'class' is where we teach an 'object' to behave." -Rich Pattis Based on slides.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Learning PowerPoint Presenting your ideas as a slide show… …on the computer!
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
Alice and Java Unit 7 1. Day 1  Objective: Gain an introduction to Java and Eclipse  Essential skill: DM-1: Use technology to advance critical thinking.
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Week 3 - Wednesday CS 113.
Manipulating Pictures, Arrays, and Loops part 2
Introduction to Computer Science / Procedural – 67130
Testing and Debugging.
CS 5010 Program Design Paradigms "Bootcamp" Lesson 9.3
Learning to program with Logo
CS190/295 Programming in Python for Life Sciences: Lecture 1
Lesson 2: Building Blocks of Programming
More Selections BIS1523 – Lecture 9.
Workshop for Programming And Systems Management Teachers
CS 2530 Intermediate Computing Dr. Schafer
Manipulating Pictures, Arrays, and Loops
Review of Previous Lesson
Presentation transcript:

TeachScheme, ReachJava Stephen Bloch, Adelphi University, Garden City, NY John Clements, Cal Poly, San Luis Obispo, CA Kathi Fisler, Worcester Polytechnic Institute, Worcester, MA Matthew Flatt, University of Utah, Salt Lake City, UT Shriram Krishnamurthi, Brown University, Providence, RI Viera K. Proulx, Northeastern University, Boston, MA Supported by NSF grant # Related work by Matthias Felleisen, Robby Findler, Kathy Gray, Eli Barzilay, et al

July TeachScheme, ReachJava What is a problem? What is the meaning of life? – Not an objective question How old am I? – An objective question, which requires information you don’t have What is the smallest prime number? – An objective, fully-specified question, but once it’s answered once, it’s over

July TeachScheme, ReachJava What is a problem? What is the Celsius equivalent of 45F? – Again, once it’s answered, it’s over What is the Celsius equivalent of 87F? – Ditto, but closely related What is the Celsius equivalent of ___ in Fahrenheit? – Generalizes infinitely many questions

July TeachScheme, ReachJava What is a problem? Question: has a single answer Problem: large (or infinite) family of questions, sharing some features & differing in others Program: general rule for solving a problem, with input for the features that differ Computation: a program working on particular input to produce particular results

July TeachScheme, ReachJava Introductions Who are you? What kind of school? students? Background in teaching CS Background in Scheme, Java, etc?

July TeachScheme, ReachJava This week You’re primarily students, not teachers Get “the student experience” of this approach — only faster Occasional breaks to talk pedagogy

July TeachScheme, ReachJava What is “computer science”? “microscope science” — about microbes “telescope science” — about stars It’s not about the tool, it’s about what you can study using the tool! “computer science” — about information and the manipulation thereof

July TeachScheme, ReachJava What is a beginning CS course about? 1)How to use Microsoft Office et al 2)Survey of the CS profession 3)A language that will get students jobs 4)Concepts, habits, & methodologies of programming Four completely different courses, each valuable for different reasons and audiences #3 useful for students about to graduate, or about to get internships and summer jobs #4 more useful as a first course. Let's call it "CS1"…

July TeachScheme, ReachJava What is CS1 about?

July TeachScheme, ReachJava What you teach blah algorithm blah variable blah function blah data type blah object blah re-use blah methodology blah testing blah design blah composition blah refinement blah abstraction

July TeachScheme, ReachJava What they hear blah ; blah { blah ) blah ] blah return blah this.x = x; blah public static void main (String[] args) blah /* blah // blah blah if ( blah JOptionPane blah class Posn(int x,y)

July TeachScheme, ReachJava Programming languages: a necessary evil Necessary: to write real programs that really run on real computers Evil: distract students from the important stuff Will be obsolete in a few years anyway

July TeachScheme, ReachJava How to minimize language & IDE? Introduce features one at a time Avoid "black magic"; never ask students to write anything they can't understand now Introduce features only as necessary to teach an important concept Corollary: any feature that doesn't help teach a CS1 concept shouldn't be mentioned in CS1 Corollary: need enforced language subsets so students don't accidentally use language features they haven't seen For GUI, robotics, networking, etc. need interface between student code (in subset) and library code (in full language)

July TeachScheme, ReachJava What Java do we need? When? Realistically, most of us must cover a certain amount of Java by the end of CS2 Not obvious that the best way to do this is Java from start of CS1 Instead, teach concepts & habits first, then complicated language

July TeachScheme, ReachJava Alternatives to Java-first Leading alternatives: Alice, Python, Scheme All three: start w/simpler syntax while students master concepts Difference: Alice & Python usually taught imperatively; Scheme usually functionally (Functional-first Python: has potential)

July TeachScheme, ReachJava Why functional? Simple, familiar semantic model – 3+4*5 => 3+20 => 23 Ease of writing test suites – each test is usually one stmt, rather than "set up", "call method", "check side effects" – tests order-independent – no worry about aliasing, equals() vs. ==, etc. – If testing is easy, students may actually do it!

July TeachScheme, ReachJava But what about OOP? Students need to learn OOP, and an OO language, by 2nd or 3rd semester OOP is a terrific way to organize multi-KLOC programs First-term students don't write multi-KLOC programs OOP's benefits aren't apparent in first term; students see only the overhead (Challenge: write a short, OO C++/Java program that wouldn't be simpler without OO)

July TeachScheme, ReachJava Main points of TSRJ Multi-language approach to CS1/CS2 – Start in Scheme, develop concepts & habits – Switch to Java after 2-4 months Step-by-step design recipe in both languages – concrete questions & products at each step – test-first methodology – strong emphasis on data types – shape of data determines shape of code & test cases DrScheme development environment – beginner-friendly – interactive testing and experimentation – enforces language subsets w/appropriate messages

July TeachScheme, ReachJava Let’s try DrScheme DrScheme Interactions pane (bottom half) Literal expressions – 7 – "hello world" – copy and paste picture from Web browser – true Try

July TeachScheme, ReachJava Operating on pictures (reflect-vert paste-picture-from-Web) Same with reflect-horiz, rotate-cw, rotate-ccw, rotate-180 (above picture1 picture2) Same with beside, overlay – These three actually accept two or more pictures. Syntax rule: ( operation pic1 … ) Terminology: expression, function, argument, value, literal

July TeachScheme, ReachJava Composing functions > (beside (reflect-horiz )) Exercise: write expressions to produce

July TeachScheme, ReachJava Scheme syntax All expressions fully parenthesized; no order of operations to memorize All functions (both built-in and user-defined) are prefix, inside parentheses Some functions have arity 1, some 2, some "2 or more", etc. as appropriate.

July TeachScheme, ReachJava Definitions pane Editable and savable "Run" button evaluates all expressions in order, replacing old Interactions Try 7 "hello world" copied image from Web (above (rotate-cw picture) (rotate-ccw picture))

July TeachScheme, ReachJava The Stepper Type several nested expressions into Definitions pane Click "Step" button at top See each sub-expression replaced with its value, one by one Valuable for students who never really "got" algebra

July TeachScheme, ReachJava Variable definitions (define calendar ) (above calendar (reflect-vert calendar)) Define another variable to hold a different picture copied from the Web; write some expressions using both. Note no declared data type; data have types, variables don't

July TeachScheme, ReachJava Building images from scratch (rectangle "solid" "blue") (circle 18 "outline" "green") (ellipse "outline" "purple") (triangle 22 "solid" "pink") (star "solid" "blue") (text "Hello there" 18 "blue") Try your own variations (define blue-star (star "solid" "blue")) Try modifying & combining these using above, overlay, reflect-vert, rotate-cw, etc.

July TeachScheme, ReachJava Terminology Three kinds of literals: image (pasted from Web browser), number, and string. Data types

July TeachScheme, ReachJava Function contracts ; reflect-vert : image -> image ; reflect-horiz, rotate-cw, rotate-ccw, rotate-180 : similar ; beside : image image … -> image ; above, overlay : similar ; rectangle : number(width) number(height) string(solid/outline) string(color) -> image Summarizes what a function takes in and returns, in a brief, standard notation Note semicolon for comment-to-end-of-line

July TeachScheme, ReachJava More image functions ; crop-bottom : image number(pixels) -> image ; crop-top, crop-left, crop-right : similar ; image-width : image -> number ; image-height : similar ; place-image : image(foreground) number(x) number(y) image(background) -> image ; text : string(text) number(size) string(color) -> image

July TeachScheme, ReachJava Defining functions > (define (mirror picture) (beside picture (reflect-horiz picture))) (mirror calendar) (mirror (rotate-cw (triangle 10 "solid" "blue"))) Note no declared parameter or return types; again, data have types Try (mirror calendar hacker) -- wrong number of arguments! Try (mirror 7) -- wrong type of argument!

July TeachScheme, ReachJava Exercise Define a function four-square that takes in an image and produces a 2x2 arrangement of it like

July TeachScheme, ReachJava Worked Exercise Define a function counterchange that takes in two images and produces a 2x2 arrangement like My answer: (define (counterchange topleft topright) (above (beside topleft topright) (beside topright topleft)))

July TeachScheme, ReachJava Testing functions With English descriptions: – (mirror calendar) "should be a calendar on the left, and a right-left-reflected calendar on the right" With check-expect: – (check-expect (mirror calendar) (beside calendar (reflect-horiz calendar))) Put either or both in Definitions window; hit Run & see what happens. Try with wrong function definition!

July TeachScheme, ReachJava Design recipes We could write counterchange in an ad-hoc way, but in general we use… Step-by-step recipes to get from English-language description to working, tested code One recipe for functions, one for data types, one for abstractions, one for event-driven animations…

July TeachScheme, ReachJava How to accomplish anything 1)Figure out what you want to do 2)Do it 3)Check that you did it right

July TeachScheme, ReachJava How to write a function/method Figure out what you want to do Contract: Specify name, inputs, outputs Data definition: Identify any new data types in the problem Examples: Write test cases with expected answers Do it Skeleton: Write boilerplate code for function definition Inventory: Write available expressions, their types, and (later) their values for a non-trivial test case Body: Fill in details based on problem to solve Check that you did it right Testing: Run test cases

July TeachScheme, ReachJava The design recipe in practice contract: ; counterchange : image (topleft) image(topright) -> image data definition: problem only involves images, which are predefined test cases: (check-expect (counterchange calendar schemelogo) (above (beside calendar schemelogo) (beside schemelogo calendar))) (check-expect (counterchange book (ellipse "outline" "pink")) (above (beside book (ellipse "outline" "pink")) (beside (ellipse "outline" "pink") book))

July TeachScheme, ReachJava The design recipe in practice skeleton: (inserted before examples) (define (counterchange topleft topright) ) inventory: (define (counterchange topleft topright) ; topleft an image ; topright an image ) body: (fill in something real, using expressions from inventory) (define (counterchange topleft topright) ; topleft an image ; topright an image (above (beside topleft topright) (beside topright topleft))) testing: hit "Run" and see whether tests pass

July TeachScheme, ReachJava The result ; counterchange : image (topleft) image(topright) -> image (check-expect (counterchange calendar schemelogo) (above (beside calendar schemelogo) (beside schemelogo calendar))) (check-expect (counterchange book (ellipse "outline" "pink")) (above (beside book (ellipse "outline" "pink")) (beside (ellipse "outline" "pink") book)) (define (counterchange topleft topright) ; topleft an image ; topright an image (above (beside topleft topright) (beside topright topleft)))

July TeachScheme, ReachJava Testing again Change the definition so that it's wrong; run the tests again and see what happens.

July TeachScheme, ReachJava Design recipes as pedagogy Note "test-first" methodology (a la XP); identify special cases before writing code Use as grading rubric: partial credit for each step First steps are in comments; non-threatening, avoids "blank page syndrome" Each step has concrete questions and concrete products I don't help with step N until I see step N-1 Same steps apply in Java, C++, etc. (but more complicated) Know-it-all students usually try to skip the recipe… until Chapter 12 of HtDP, or Chapter 23 of PP…

July TeachScheme, ReachJava Exercises Write contracts and test cases, but no definitions, for 1)a function named copies-beside that takes in a number and an image, and produces that many copies of the image side by side 2)a function named pinwheel that takes in an image & produces a 2x2 rotated thing like 3)a function named checkerboard2 that takes in two color names & produces a 2x2 checkerboard in those colors

July TeachScheme, ReachJava Exercises Write skeletons & definitions for pinwheel and checkerboard2 (you don't know how to do copies- beside yet) Do all the steps to define lollipop, which takes in two numbers and a color name, and creates a picture of a lollipop w/specified radius, stick length, and color

July TeachScheme, ReachJava Exercises Do all the steps to define diamond, which takes in a color name and a number, and creates a picture of a diamond w/specified color and side length.

July TeachScheme, ReachJava Discussion break How is this different from what you've done in the past? How much explaining would it take for your students? I have a lot of mathophobic students, so I start with images rather than numbers and algebra. The prefix notation doesn't throw them, because they don't already "know" the "right" notation for operating on images.