Download - CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

Transcript
Page 1: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

Thisdocumentiscopyright(C)StanfordComputerScienceandMartyStepp,licensedunderCreativeCommonsAttribution2.5License.Allrightsreserved.BasedonslidescreatedbyKeithSchwarz,MehranSahami,EricRoberts,StuartReges,andothers.

CS106A,Lecture1WelcometoCS106A!

suggestedreading:CourseInformationhandout

Karel,Ch.1-2

Page 2: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

2

Plan For Today•Introduction•CoursePolicies•MeetKareltheRobot

Page 3: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

3

Plan For Today•Introduction•CoursePolicies•MeetKareltheRobot

Page 4: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

4

What is Computer Science?• Theartofusingcomputingtosolvecomplexproblems.

– Specifyinstructions thatcomputersexecute,usuallyinaprogramminglanguage

• Applicabletoart,medicine,mathematics,philosophy,andmore• Touchesmanyaspectsofourdailylives

Page 5: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

5

Computing is Everywhere• >3.5Busersoftheinternet(internetlivestats.com)• 39%ownedasmartphonein2016(strategyanalytics.com)• Acomputerrecentlydefeatedtheworld-championGoplayer• Machinetranslationhastakendramaticleapsinthepastyear

Page 6: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

6

What is CS 106A?• ProgrammingMethodology

– Focusingoncomputationalproblemsolving,notsyntax– UsestheJava programminglanguage– Noformerprogrammingexperiencerequired!

• Topicsinclude:– KareltheRobot– Text-basedprograms– Graphicsandanimation– Games– Andmore…

Page 7: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

7

Course Website

cs106a.stanford.edu

Page 8: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

8

Nice to meet you!

Page 9: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

9

Section Leaders• Helpfulundergraduateassistantswhowill:

– runyourdiscussionsectioneachweek– gradeyourhomeworkassignmentsandexams– helpyouwhenyouhavequestions– ...andmuchmore

Page 10: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

10

Nice to meet you!

Page 11: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

11

Nice to meet you!

Page 12: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

12

Plan For Today•Introduction•CoursePolicies•MeetKareltheRobot

Page 13: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

13

Units

Matriculated Stanford grad?

Page 14: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

14

Course Website

cs106a.stanford.edu

Page 15: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

15

Textbooks• KareltheRobotLearnsJava,coursereader (35pages)

– usedthisandnextweekasweintroducecoding– usableonopen-book(closed-note)exams– FreePDFavailableonline

• TheArt&ScienceofJava,byEricRoberts– writtenhereatStanford;tailoredtothiscourse;avaluablereference– usableonopen-book(closed-note)exams– availableonreserveatlibrary

Page 16: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

16

Grading****** 45% Programmingassignments* 10% SectionParticipation** 15% MidtermExam**** 30% FinalExam

Page 17: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

17

Grading****** 45% Programmingassignments* 10% SectionParticipation** 15% MidtermExam**** 30% FinalExam

Page 18: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

18

Programming Assignments• 6 programmingassignments(someindividual,someinpairs),completedusingEclipse

• gradedonfunctionality (behavior)andstyle (elegance)– Interactivegradingsessionsforeveryassignment– gradingscaleisdividedinto"buckets”

• Freesoftware,availableoncoursewebsite

• Homework: setupEclipse!• CometoLaIR thisWed.7-11PM fortroubleshooting

Page 19: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

19

The Bucket System

√ satisfactory;meetsrequirements,maybeafewissues

Page 20: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

20

The Bucket System

√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues

Page 21: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

21

The Bucket System

√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements

Page 22: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

22

The Bucket System

+ Exceedsexpectations;oftenreflectsadditionalwork√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements

Page 23: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

23

The Bucket System

+ Exceedsexpectations;oftenreflectsadditionalwork√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements- Extremelyseriousproblems,alittleeffortandunderstanding

Page 24: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

24

The Bucket System++ Absolutelyfantasticsubmission(veryrare)+ Exceedsexpectations;oftenreflectsadditionalwork√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements- Extremelyseriousproblems,alittleeffortandunderstanding

Page 25: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

25

The Bucket System++ Absolutelyfantasticsubmission(veryrare)+ Exceedsexpectations;oftenreflectsadditionalwork√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements- Extremelyseriousproblems,alittleeffortandunderstanding-- Littleeffort

Page 26: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

26

The Bucket System++ Absolutelyfantasticsubmission(veryrare)+ Exceedsexpectations;oftenreflectsadditionalwork√+ Welldone;satisfiesallassignmentrequirements√ satisfactory;meetsrequirements,maybeafewissues√- Problemsseriousenoughtofallshortofassignmentrequirements- Extremelyseriousproblems,alittleeffortandunderstanding-- Littleeffort0 Nosubmission

Page 27: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

27

Getting Help• VisittheSLsintheLaIR (1stfloorofTresidder Union)

– openSun-Wed,7PM– 11PM,startingthisWednesday– staffedwithmultiplesectionleaderstoanswerquestions

• otherhelpresources:– instructorofficehours– headTAofficehours– emailSL,TA,instructor

• EclipsetroubleshootingsessionWednesday6/287-11PM@LaIR

Page 28: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

28

2 Minds are Better Than 1• Someassignmentsmayoptionallybedoneinpairs• Bothpartnersreceivethesamegrade• Achancetobrainstormideasandworkwithanotherprogrammer• MUSTbeinthesamesection!• Moreinfoinhandout#1andonthecoursewebsite

Page 29: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

29

Interactive Grading• Foreachassignment(exceptforthelast),youwillgetfeedbackviaanInteractiveGrading (IG)session,scheduledwithyoursectionleader.

• Gooverassignmentfeedback,strengths,thingstoimprove

Page 30: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

30

Late Days• Startoutwith3“freelatedays”:eachlatedayallowsyoutosubmitanassignment24hourslatewithoutpenalty.

• Harddeadline48hoursafteroriginalduedate• 1-bucketdeductionperdaylateafterlatedaysareexhausted• Pairlatedaysareassessedindividually• ”Pre-grantedextensions”– additionalextensionsgrantedonlyinveryspecialcircumstances.HeadTAmustapproveextensions.

Page 31: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

31

Grading****** 45% Programmingassignments* 10% SectionParticipation** 15% MidtermExam**** 30% FinalExam

Page 32: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

32

Discussion Sections•Weekly50-minutesectionsledbyyoursectionleader•Gooverlecturematerial,dopracticeproblems,answerquestions

•Gradedonsectionattendance+participation(+IGattendance)

•Homework:signupforsectiononthecoursewebsite!

Page 33: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

33

Grading****** 45% Programmingassignments* 10% SectionParticipation** 15% MidtermExam**** 30% FinalExam

Page 34: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

34

Exams•Midtermexam– Monday,July24th,7-9PM

– ContactmebyJuly17 ifyouhaveanacademicorUniversityconflict

• Finalexam – Friday,August18th,12:15-3:15PM– Noalternatefinal!YouMUST beabletotakethefinalexamatthescheduledtime.

• Bothexamsareopen-book,closed-notes,closed-electronic-device.Youwillbeprovidedwithasyntaxreferencesheet.

Page 35: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

35

Grading****** 45% Programmingassignments* 10% SectionParticipation** 15% MidtermExam**** 30% FinalExam

Page 36: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

36

Stanford Honor Code• TheHonorCode isanundertakingofthestudents,individuallyandcollectively:

– thattheywillnotgiveorreceiveaidinexaminations;thattheywillnotgiveorreceiveunpermittedaidinclasswork,inthepreparationofreports,orinanyotherworkthatistobeusedbytheinstructorasthebasisofgrading;

– thattheywilldotheirshareandtakeanactivepartinseeingtoitthatothersaswellasthemselvesupholdthespiritandletteroftheHonorCode.

• Thefacultyonitspartmanifestsitsconfidenceinthehonorofitsstudentsbyrefrainingfromproctoringexaminationsandfromtakingunusualandunreasonableprecautionstopreventtheformsofdishonestymentionedabove.Thefacultywillalsoavoid,asfaraspracticable,academicproceduresthatcreatetemptationstoviolatetheHonorCode.

• Whilethefacultyalonehastherightandobligationtosetacademicrequirements,thestudentsandfacultywillworktogethertoestablishoptimalconditionsforhonorableacademicwork.

seealso:http://honorcode.stanford.edu/

Page 37: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

37

Honor Code and CS 106A• Pleasehelpusensureacademicintegrity:

– IndicateanyassistancereceivedonHW(books,websites,friends).– Donotlookatotherpeople'ssolutioncode(outsideofyourpair).– Donotgiveyoursolutioncodetoothers,orpostitontheweb.– Reportanyinappropriateactivityyouseeperformedbyothers.

• Assignmentsarecheckedregularlyforsimilaritywithhelpofsoftwaretools.

• Ifyourealizethatyouhavemadeamistake,youmayretractyoursubmissiontoanyassignmentatanytime,noquestionsasked.

• Ifyouneedhelp,pleasecontactusandwewillhelpyou.– WedonotwantyoutofeelanypressuretoviolatetheHonorCodeinordertosucceedinthiscourse.

Page 38: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

38

Plan For Today•Introduction•CoursePolicies•MeetKareltheRobot

Page 39: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

39

Meet Karel the Robot!

Page 40: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

40

Meet Karel the Robot!

Hello, world!

Page 41: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

41

Programming languages• procedurallanguages:programsareaseriesofcommands

– Pascal (1970): designedforeducation

– C (1972): low-leveloperatingsystemsanddevices

• functionalprogramming:functionsmapinputstooutputs– Lisp (1958)/Scheme (1975),ML (1973),Haskell (1990)

• object-orientedlanguages:programsuseinteracting"objects"

– Smalltalk (1980):firstmajorobject-orientedlanguage

– C++ (1985): "object-oriented"improvementstoC• successfulinindustry;usedtobuildOSessuchasWindows

– Java (1995): designedforembeddedsystems,webapps• Runsonmanyplatforms(Windows,Mac,Linux,cellphones...)• Thelanguagetaughtinthiscourseandourtextbook

Page 42: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

42

Karel's World

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Page 43: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

43

Karel's World

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Page 44: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

44

Karel's World

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Hello, world!

Page 45: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

45

Karel's World

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Page 46: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

46

Streets (rows)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5Each row is called a

street.

Page 47: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

47

Avenues (columns)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Each column is called an avenue.

Page 48: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

48

Corners (locations)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

The intersection of a street and an avenue is a corner.

Page 49: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

49

Walls

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5Karel cannot move through

walls.

Page 50: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

50

Beepers

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

2

3

1 2 3 4 5

Beepers mark locations in Karel's world. Karel canpick them up andput them down.

Page 51: CS 106A, Lecture 1 - Stanford University · CS 106A, Lecture 1 Welcome to CS 106A! ... •Introduction ... –Specify instructionsthat computers execute, usually in a programming

51

Wrap-up•Introduction√•CoursePolicies√•MeetKareltheRobot√

Nexttime:moreprogrammingwithKarel!