Welcome to CS 5 ! Introduction to CS Of all the classes I took, this was one of them. an advocate of concrete computing When CS 5 was over, I knew it was a good thing. - Ebert and Roeper’s course reviews Meeting Times and Places Lab Required ! M and W: 4-5 pm in the Academic Computing (AC) Labs T and Th: 2:30-3:30 pm AC Labs are in Parsons 146 Chance to work on HW problems & ask questions PC: M-Z Alternate using the Macs and the PCs . Mac: A-J by last name alternating each week... Meeting Times and Places Lab Required ! M and W: 4-5 pm in the Academic Computing (AC) Labs T and Th: 2:30-3:30 pm AC Labs are in Parsons 146 Chance to work on HW problems & ask questions PC: M-Z Alternate using the Macs and the PCs . Mac: A-J by last name alternating each week... Lecture Strongly encouraged M and W: 2:45-4:00 pm (or so) here in Galileo Pryne T and Th: 1:15-2:30 pm (or so) here in Galileo Pryne Insight into the HW problems (what, why, how) Meeting Times and Places Lab Required ! M and W: 4-5 pm in the Academic Computing (AC) Labs T and Th: 2:30-3:30 pm AC Labs are in Parsons 146 Chance to work on HW problems & ask questions PC: M-Z Alternate using the Macs and the PCs . Mac: A-J by last name alternating each week... Lecture Strongly encouraged Recitation All are welcome M and W: 2:45-4:00 pm (or so) here in Galileo Pryne T and Th: 1:15-2:30 pm (or so) here in Galileo Pryne Insight into the HW problems (what, why, how) 8:00 - 9:00 am Fridays in Galileo Edwards More insight into the HW problems (how) NO recitation this week -- it’s for Monday’s section only! Resources Course Web Page: http://www.cs.hmc.edu/courses/2004/fall/cs5 all assignments, online text, necessary files, lecture slides are here First week’s assignment: Reading Wk 1 and starting on Hw 2. Resources Course Web Page: http://www.cs.hmc.edu/courses/2004/fall/cs5 all assignments, online text, necessary files, lecture slides are here First week’s assignment: Reading Wk 1 and starting on Hw 2. Course Mailing List reminders and hints CS 5 vs. spam! Resources Course Web Page: http://www.cs.hmc.edu/courses/2004/fall/cs5 all assignments, online text, necessary files, lecture slides are here First week’s assignment: Reading Wk 1 and starting on Hw 2. Course Mailing List reminders and hints CS 5 vs. spam! Old Compiler: CodeWarrior Learning Edition 3.0 $35 that smile... ?! Resources Course Web Page: http://www.cs.hmc.edu/courses/2004/fall/cs5/ all assignments, online text, necessary files, lecture slides are linked First week’s assignment: Reading Wk 1 and starting on HW 2. Course Mailing List reminders and hints XCode - Mac Compiler: JCreator or XCode/Proj. Builder Price: $0 ! With many other advantages, as well... available from www.cs.hmc.edu/~dodds/cs5 JCreator - PC Homework Assignments 4-5 problems (50 points) per week, 20% extra credit Monday’s section Tuesday’s section Wednesday’s section Thursday’s section due Sunday 11:59 pm due Monday 11:59 pm Working on programs: save in your CHARLIE home directory (H:) saving on the C: drive is OK on your machine, of course! Submitting Programs: on line from the course website Working on different machines: submit and download You’ll need the supporting files for each machine you’ll be using These are all available from the CS 5 website (Hw2Pr1.zip, etc.) Grading Grades Based on points percentage ~ 50% Assignments ~ 30% Exams ~ 20% Participation if (score >= 95%) {grade = “A”;} if (score >= 95%) {grade = “HP”;} if (score >= 60%) {grade = “P”;} see course syllabus for the full grade list... Grading Grades Based on points percentage ~ 50% Assignments ~ 30% Exams ~ 20% Participation Exams Midterm #1 Midterm #2 Final if (score >= 95%) {grade = “A”;} if (score >= 95%) {grade = “HP”;} if (score >= 60%) {grade = “P”;} see course syllabus for the full grade list... Friday, October 8 Friday, November 12 To be announced if (currentgrade == “A”) 50 points each 300 points { takeexam = false; } Grading Grades Based on points percentage ~ 50% Assignments ~ 30% Exams ~ 20% Participation Exams Midterm #1 Midterm #2 Final if (score >= 95%) {grade = “A”;} if (score >= 95%) {grade = “HP”;} if (score >= 60%) {grade = “P”;} see course syllabus for the full grade list... Friday, October 8 Friday, November 12 To be announced if (currentgrade == “A”) 50 points each 300 points { takeexam = false; } Already know programming …? Work ahead! You may submit assignments 5, 10, and 14 instead of an earlier assignment. If you receive at least an 80%, those lab sessions are not required, and you will receive the same grade on the intervening hwks. but email me if you do this... Resources Instructors Zach Dodds Belinda Thom Office: Olin 1265 Olin 1241 Phone: x78990 (909-607-8990) x79662 Email: dodds@cs.hmc.edu bthom@cs.hmc.edu Official Office Hrs: F 9-12 TTh 4:30-6 Real Office Hrs: come by anytime… Graders / Tutors available in the LAC and Parsons computer labs • during afternoon lab sessions • Saturday and Sunday afternoons • Sunday and Monday evenings • you can also track them down elsewhere... names linked from the webpage Other Students The Honor Code and Computer Science... Honor Code • You are encouraged to discuss problems with other students. • You may not share written, electronic or verbal solutions with other students (present or past): No copying of files except those provided by the course material. No transcribing of programs from paper, whiteboards, blackboards, or other media. Starting with week 3 (Hw3), you will have the option of working in pairs for one of each week’s problems. (The same guidelines apply for each pair.) Questions ? Welcome to CS 5 ! Introduction to CS Of all the classes I took, CS 5 was one of them. When CS 5 was over, I knew it was a good thing. an advocate of concrete computing Not as poignant as Jason vs. Freddy, but at least as gory! - Ebert and Roeper’s course reviews Welcome to CS 5 ! Computer Psychology Of all the classes I took, CS 5 was one of them. When CS 5 was over, I knew it was a good thing. an advocate of concrete computing Not as poignant as Jason vs. Freddy, but at least as gory! - Ebert and Roeper’s course reviews Goals class S{public static void main(String[]a){String s= "class S{public static void main(String[]a){String s= ;char c=34;System.out.println(s.substring(0,52)+c+s +c+s.substring(52));}}” ;char c=34;System.out.println(s.substring(0,52)+c+s +c+s.substring(52));}} ouch! Goals class S{public static void main(String[]a){String s= "class S{public static void main(String[]a){String s= ;char c=34;System.out.println(s.substring(0,52)+c+s +c+s.substring(52));}}” ;char c=34;System.out.println(s.substring(0,52)+c+s +c+s.substring(52));}} ouch! thinking like a machine ENIAC, 1945 Not why... Java is the programming language of the future Programming will solve problems for you Programming will save time && effort Not why... Java is the programming language of the future Programming will solve problems for you Programming will save time && effort 2 ampersands in Java (&&) means and Why ? Science is about explaining and understanding data. Computer Science provides powerful tools to do this. simulation analysis How do we represent physical phenomena … ? How does each object affect others … ? http://heat.usc.edu/test/new/HSgas.html N-body problem How many forces do we need to keep track of … ? Why Java ? Java is a general-purpose computer language laser-testing code in LabView Engineering: Matlab, Electric, E4 Physics: LabView Chemistry: Rasmol, Kaleidograph Math: Maple, ODE Architect Biology: Populus, Lasergene & lots more special-purpose packages sequence-matching in Lasergene But ... I can be a physicist, chemist, engineer, biologist, mathematician, high-school teacher, Fear Factor contestant, or CEO of the next Microsoft, ... without programming || computer science But ... I can be a physicist, chemist, engineer, biologist, mathematician, high-school teacher, Fear Factor contestant, or CEO of the next Microsoft, ... without programming || computer science or But ... I can be a physicist, chemist, engineer, biologist, mathematician, high-school teacher, Fear Factor contestant, or CEO of the next Microsoft, ... without programming || computer science Yes, if you’re 60 Maybe, if you’re 20 But ... intuition about the machines you’ll be using will make you more effective at all of the above. What is programming ? Programming == recipe-writing What is programming ? Programming == recipe-writing is What is programming ? Programming == recipe-writing Programming == learning a foreign language What is programming ? Programming == recipe-writing Programming == learning a foreign language Baggage ! What is programming ? Programming == recipe-writing Programming == learning a foreign language Baggage ! class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } What is programming ? Programming == recipe-writing Programming == learning a foreign language Baggage ! class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } Syntax: What is programming ? Programming == recipe-writing Programming == learning a foreign language Baggage ! class CS5App week 10 { week 13 week 5 week 2 week 2 public static void main(String[] args) week 7 { System.out.println("Hello World!"); } } What is all of this stuff ? && Why is it here ? go/went Java baggage #1 -- Punctuation /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } // start here Java baggage #1 -- Punctuation /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } Punctuation: { curly braces create code blocks } “ double quotes create a literal string ” // start here matched Java baggage #1 -- Punctuation /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } Punctuation: { curly braces create code blocks } “ double quotes create a literal string ” . the “dot” indicates containment ; a semicolon ends a statement // start here matched unmatched Java baggage #2 -- Comments /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } Two types of comments: // // start here rest-of-line comment /* one-or-more-line comment */ Java baggage #3 -- Spacing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } // start here programs that look identical to Java... /* A Hello, World program class CS5App { public */ static void main(String[] System.out.println( "Hello World!") ;}} args){//starthere Java baggage #3 -- Spacing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Hello World!"); } } // start here 3. Spacing almost completely ignored by silicon almost completely essential for carbon these 1. aligning punctuation 2. commenting 3. adequate spacing are the essential style guidelines If you don’t space... riverrunpastEveandAdamfromsw erveofshoretobendofbaybringsusb yacommodiusvicusofrecirculation backtoHowthCastleandEnvirons. If you don’t space... riverrunpastEveandAdamfromsw erveofshoretobendofbaybringsusb yacommodiusvicusofrecirculation backtoHowthCastleandEnvirons. riverrun past Eve and Adam from swerve of shore to bend of bay brings us by a commodius vicus of recirculation back to Howth Castle and Environs. James Joyce Java baggage #4 -- main /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Harvey"); System.out.print(“Mu"); } } main // start here is where it all begins... Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Harvey"); System.out.print(“Mu"); } } text output // start here H.out.println(“dd”); H.out.print(“col”); H.p(“leg”); H.pl(“e”); Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Harvey"); System.out.print(“Mu"); } } System.out H.out H are all basically the same. // start here H.out.println(“dd”); H.out.print(“col”); H.p(“leg”); H.pl(“e”); Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Harvey"); System.out.print(“Mu"); } } System.out H.out H are all basically the same. So, use H ! // start here H.out.println(“dd”); H.out.print(“col”); H.p(“leg”); H.pl(“e”); Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.println("Harvey"); System.out.print(“Mu"); } } // start here goes to next line at end stays on same line at end H.out.println(“dd”); H.out.print(“col”); stays on same line at end goes to next line at end H.p(“leg”); H.pl(“e”); \n puts a new line anywhere If Joyce wrote in code... For example, H.out.print(“hvm\naeu\nryd”); H.out.println(“whteu\naerae”); H.out.print(“vyrao\noeg”); H.out.println(“dn\nbooe.”); If Joyce wrote in code... For example, H.p(“hvm\naeu\nryd”); H.pl(“whteu\naerae”); H.p(“vyrao\noeg”); H.pl(“dn\nbooe.”); Language is language PLEASE DO ,1 <- #13 DO ,1 SUB #1 <- #238 DO ,1 SUB #2 <- #112 DO ,1 SUB #3 <- #112 DO ,1 SUB #4 <- #0 DO ,1 SUB #5 <- #64 DO ,1 SUB #6 <- #238 DO ,1 SUB #7 <- #26 DO ,1 SUB #8 <- #248 DO ,1 SUB #9 <- #168 DO ,1 SUB #10 <- #24 DO ,1 SUB #11 <- #16 DO ,1 SUB #12 <- #158 DO ,1 SUB #13 <- #52 PLEASE READ OUT ,1 PLEASE GIVE UP Intercal v >v"Hello world!"0< ,: ^_25*,@ Befunge LISP/Scheme (DEFUN HELLO-WORLD () (PRINT (LIST 'HELLO 'WORLD))) #include <iostream> int main() { std::cout << "Hello, world!"; } print "Hello, World!"; Perl C++ Language is language ? Perls of wisdom ? eval evalq.q>trd!Uj:%L<061:%C<csnvo:%f<fsddo0:%c<cmtd:%x<xdmmnv:%I<011:%u<251:%bs<bsd`udSdbu`ofmd:%w<lnwd:%U<2:%t<L`hoVhoenv,? odv),idhfiu<?314-,vheui<?254(:%b<%t,?B`ow`r:%b,?bnoghftsd),vheui<?%u-,idhfiu<?311(:%b,?q`bj)(:s)3-3-%u-001-%c(:s)3-081-%u-311 -%f(:s)3-001-%u-031-%f(:s)3-1-%u-34-%f(:gns)%{<1:%{=%u:%{*<71(zs)%{-01-%{*51-54-%f-%f(:|s)3-1-%u-04-cm`bj(:%b,?%bs)3-1-%u-311 (:%G<,041:v)1-%L-31-C-%x(:v)%G-%L-,021-C-%x(:%B<,91:v),31-041-,4-B-%c(:v),91-041-,74-B-%c(:%E<,%I:v)1-021-31-E-%x(:v),%I-021-, 91-E-%x(:%K<,231:v),71-81-,31-@-%C(:v),301-81-,%L-@-%C(:v),%u-81-,211-@-%C(:%M<,%u:v),51-61-1-F-%C(:v),%L-61-,021-F-%C(:v),%u -61-,211-F-%C(:%J<%u:v)751-41-791-[-%C(:v)401-41-441-[-%C(:v)%u-41-291-[-%C(:%b,?bsd`udNw`m)063-080-091-088-,u`fr<?G-,ghmm<?f sddo5(:S)1(:%b,?sdqd`u)%I-]'t(:%t,?choe)&=Envo?&<?rtczS),0(:'V:%b,?%w)G-1-31(hg)%x=081(:|(:%t,?choe)&=Tq?&<?rtczS)0(:%b,?%w)G -1-,31(:|(:%t,?choe)&=Mdgu?&<?rtcz'V:%b,?%w)G-,31-1(hg)%y?31(:|(:%t,?choe)&=Shfiu?&<?rtcz'V:%b,?%w)G-31-1(hg)%Y=%u,31(:|(:L`h oMnnq)(:dyhu:rtc!vz%b,?%bs)%^Z1\-%^Z0\-%^Z3\-%^Z0\*8-,u`fr<?%^Z2\-,ghmm<?%^Z5\(:|rtc!tzhg)%G?%u(z%G*<%L:%d<,%G:%G<,%L:|dmrdz% G*<01:%d<01:|%b,?%w)C-%d-1(:hg)%B?%u(z%B*<%I:%d<,%B:%B<,%I:|dmrdz%B*<01:%d<01:|%b,?%w)B-%d-1(:hg)%E?%u(z%E*<031:%d<,%E:%E<,03 1:|dmrdz%E*<01:%d<01:|%b,?%w)E-%d-1(:hg)%K?%u(z%K*<229:%d<,%K:%K<,251:|dmrdz%K*<7:%d<7:|%b,?%w)@-%d-1(:hg)%M?%u(z%M*<271:%d<, %M:%M<,271:|dmrdz%M*<9:%d<9:|%b,?%w)F-%d-1(:hg)%J=,%u(z%J,<%u:%d<,%J:%J<%u:|dmrdz%J,<7:%d<,7:|%b,?%w)[-%d-1(:'V:hg)%x=081(zhg ))%x?031(}})%x=001((zAn<%b,?ghoe)nwdsm`qqhof-%y-%x-%Y-%X(:hg)%x?031(zhg)%"n(z'R:||dmrdzhg)%x?58(zhg)%"n?0(z%n<7:%n*<3hg)%x=81 (:%n<,7hg)%x=61(:%b,?%w)G-%n-1(:|dmrdz'R:||dmrdzhg)%"n?0(z'R:|dmrdzS)00(:%U**:%O**:'R:v)%y-%x-%Y-Q-%f(:%b,?edmdud)&Q&(hg))%O$ 4((:||||rmddq)4(''Uj;;dyhu)1(hg)%U=0(:||rtc!Rz%U,,:qshou#]`#:%b,?%w)G-063,%y-081,%x(:|rtc!SzP)cm`bj(:%R*<%^Z1\:P)sde(: |rtc!P z%b,?bsd`udUdyu)%L-9,udyu<?%R/1-,ghmm<?%^Z1\(:|rtc!sz%b,?%bs)%^Z1\-%^Z0\-%^Z3\-%^Z2\-,ghmm<?%^Z5\-,ntumhod<?%^Z4\(:|rtc!Vz)%y -%x-%Y-%X(<%b,?bnnser)G(:|>^chr($$/$$)x2016. $;=$_;$/='0#](.+,a()$=(\}$+_c2$sdl[h*du,(1ri)b$2](n}/1)1tfz),}0( o{=4s)1rs(2u;2(u",bw2b$hc7s"tlio,tx[{ls9r11$e(1(9]q($,$2)=)_5{4* s{[9$,lh$2,_.(ia]7[11f=*2308t$$)]4,;d/{}83f,)s,65o@*ui),rt$bn;5( =_stf*0l[t(o$.o$rsrt.c!(i([$a]$n$2ql/d(l])t2,$.+{i)$_.$zm+n[6t(e 1+26[$;)+]61_l*,*)],(41${/@20)/z1_0+=)(2,,4c*2)\5,h$4;$91r_,pa,) $[4r)$=_$6i}tc}!,n}[h$]$t0rd)_$';open(eval$/);$_=<0>;for($x=2;$x <666;$a.=++$x){s}{{.|.}};push@@,$&;$x==5?$z=$a:++$}}for(++$/..su bstr($a,1885)){$p+=7;$;.=$@[$p%substr($a,$!,3)+11]}eval$; back to Java The Plan Representation Naming things int double String boolean true false float short long char byte void Information Flow Making decisions if else switch for while do return break case Using/Building Structures [ ] Abstraction ! new class private static super public Weeks 2-6 functions, methods, variables Weeks 3-4 conditionals, loops Weeks 1-14 arrays, classes, design Abstraction Artists are mystics rather than rationalists. They leap to conclusions that logic cannot reach. -- Sol LeWitt, conceptual artist Simplicity does not precede complexity, but follows it. -- Alan Perlis, creator of the first compiler Abstract(ion) Art class CS5App { public static void main(String[] args) { GrCanvas art = G.createCanvas(); // the window (canvas) art.add(new GrRectangle(1,3,6,4,Color.red)); // what ?? } } Abstract Art 10 x 10 grid art.add(GrRectangle(1,3,6,2,Color.red)); Abstract Art 10 x 10 grid art.add(GrRectangle(1,3,6,2,Color.red)); Abstract Art 10 x 10 grid art.add(GrRectangle(1,3,6,2,Color.red)); art.add(GrRectangle( )); art.add(GrRectangle( )); Assignment 2, Problem 2 Create the following “work”: art.add(new art.add(new art.add(new art.add(new GrRectangle(…)); GrRectangle(…)); GrRectangle(…)); GrRectangle(…)); … Computer Science • Representing it -- what’s convenient and available ? Information • Applying it -- graphics, robotics, vision, AI • Measuring it -- what’s possible and what’s not How many drawing commands are really necessary ? Computer Science • Representing it -- what’s convenient and available ? Information • Applying it -- graphics, robotics, vision, AI • Measuring it -- what’s possible and what’s not How many drawing commands are really necessary ? 23 kb file 31 kb file In a nutshell... The purpose of computing is insight, not numbers. – Richard Hamming Programming is deceptively easy. – thanks to Steven Pinker Mac: A-J Lab Today PC: M-Z Work on the problems of Homework 2 : Hw2Pr1) The “Hello, World!” program (Today) Hw2Pr2) Abstract(ion) Art Hw2Pr3) A printing puzzle... Hw2Pr4) Artificial Intelligence (Next week) (or submit hw5...) Please complete your CS 5 “quiz” & take a photo… • Not an HMC student ? See me for an HMC account + building access “Quiz” • Name • Birthdate • A place you consider home • Your favorite _________ is _________. • Your least favorite ________ is _________. • Email and School (if not an HMC student) Be sure to have a photo taken ! “Quiz” • Name Zach Dodds • Birthdate 01/21/1969 • A place you consider home Pittsburgh, PA adhesive is _________. • Your favorite _________ duct tape canned meat product • Your least favorite ________ is _________. spam • Email and School (if not an HMC student) dodds@cs.hmc.edu Questions ? Questions ? • How do I submit things ? • Does CodeWarrior run from student rooms ? • Can I work on Assignment 5 now ? • What’s the best thing to work on in lab ? Resources Instructors Zach Dodds Office: Olin 1265 Phone: x78990 (909-607-8990) Email: dodds@cs.hmc.edu Official Office Hours: F 9-12 Real Office Hours: Any time or by email... Graders / Tutors available in the LAC and Parsons computer labs • during afternoon lab sessions • Saturday and Sunday afternoons • Sunday and Monday evenings • you can also track them down elsewhere... names linked from the webpage Other Students The Honor Code and Computer Science... CS 5 developments • The submission system won’t be up until September 10th... • CodeWarrior doesn’t work from student rooms right now -likely it will be available only from labs for the term! (of course if you have your own copy, it will work) • Assignments 1, 2, and 3 are ready. 4 and 5 will be by 9/12. • Make a CS 5 folder in your KATO home directory. Save everything there! Stuff saved elsewhere will be lost! Class Meetings Lab Required ! 2:15 - 3:15 in the Academic Computing (AC) Labs Chance to work on HW problems & ask questions Alternate Mac/PCs . This week Mac: A-M PC: N-Z Kato password w/ more than 8 letters?? -- Change it on the PC! Lecture Strongly encouraged Recitation All are welcome 1:15 - 2:15 (or so) here in Galileo Pryne Insight into the HW problems (what, why, how) 8:00 - 9:00 Fridays in Galileo Macalister More insight into the HW problems (how) do NOT come this week -- it’s for Monday’s section only! Homework Assignments 4-5 problems (50 points) per week, 20% extra credit Monday’s section Tuesday’s section Wednesday’s section Thursday’s section Grading 8 points for correctness due Sunday 11:59 pm due Monday 11:59 pm 8 points if it completely works 6 points if it almost completely works 3 points if it mostly works 0 points if it doesn’t mostly work 2 points for commenting and formatting 0 points if the code does not compile! Homework Assignments 4-5 problems (50 points) per week, 20% extra credit Monday’s section Tuesday’s section Wednesday’s section Thursday’s section due Sunday 11:59 pm due Monday 11:59 pm Alan Perlis If a listener nods his head when you're explaining your program, wake him up. A program without a loop and a structured variable isn't worth writing. Simplicity does not precede complexity, but follows it. The goal of computation is the emulation of our synthetic abilities, not the understanding of our analytic ones. A year spent in artificial intelligence is enough to make one believe in God. You think you know when you can learn, are more sure when you can write, even more when you can teach, but certain when you can program. A programming language is low level when its programs require attention to the irrelevant. An Education Is What Remains When We Forget Everything We've Learned An education is what remains when you’ve forgotten everything you've learned Language is language familiar and sometimes not so familiar… deceptively easy There’s baggage to get used to. Java programming -- writing a recipe programming -- learning a foreign language scare you w/Hello, world in other languages… really no scarier than being raised to learn Finnish or whatever syntax hello, world static, public… Java’s baggage /* A Hello, World program */ class CS5App { public static void main(String[] args) // start here { H.out.println("Hello World!\nHow are you?"); H.in.nextLine(); } } 6. Input H.in.nextLine(); worthwhile? CGU slides Why ? IS is about • explaining and understanding data • leveraging technologies economically • promoting relationships with people Computer Science provides a set of tools to help. simulation analysis filtering communication N-body problem How difficult is this? Name calling Weeks 2-3 Naming things Java gender -- example from book flavor (up,down,charm,strange,top,bottom) Type: integer value (int), sequence of characters (String), double-precision value (double), ... Representation Information Flow Naming actions mood -- Go! But if she were to go… There he goes. transitive/intransitive H.out.println(); H.in.nextLine(); Decisions, decisions Weeks 3-5 Java Big Idea: information flow Name things Name actions Make decisions And more of the same… if…then puzzle room draw! loop = pattern complexity reducing intelligent?! no enough to build an intelligent agent?! The Key building structures out of raw actions any skilled trade building structures out of raw data any skilled trade building structures out of both actions and data it can take care of itself! key: building things = abstraction … why? Week 5 Weeks 6-9 Weeks 10-14 Computer Science The science of information transistors & electrons, quantum gates and particle superpositions, recombinant molecules, analog computing • representing it -- what’s convenient for the electrons? programming • changing its form -- what’s convenient for us? algorithms, complexity • applying it -- AI, graphics, robotics, ... computability • measuring it -- complexity -- what’s possible? algorithms -- minimal number of drawing commands Abstract(ion) Art computer science is fundamentally a referential subject... recognition that you don’t really need to know all the details, you just need to know where to get them and how to use them from there Expert Advice Get into a rut early -- do the same process the same way. Accumulate idioms and standardize! It is Shakepeare’s idiom list, not his vocabulary, that distinguishes him. – Alan Perlis If you don’t space... riverrunpastEveandAdamfromsw erveofshoretobendofbaybringsusb yacommodiusvicusofrecirculation backtoHowthCastleandEnvirons. If you don’t space... riverrunpastEveandAdamfromsw erveofshoretobendofbaybringsusb yacommodiusvicusofrecirculation backtoHowthCastleandEnvirons. riverrun past Eve and Adam from swerve of shore to bend of bay brings us by a commodius vicus of recirculation back to Howth Castle and Environs. James Joyce Silicon Dreams How does a machine think ? Silicon Dreams How does a machine think ? Algorithms How many problems am I facing ? Programming Language p = 5*12; Machine Instructions load p 5 mult p 12 Movement of electrons layers of abstraction Shockley’s first transistor its greatgreat-… grandchild Silicon Dreams How does a machine think ? Algorithms our tasks How many problems am I facing ? Programming Language p = 5*12; Machine Instructions load p 5 mult p 12 Java computer’s tasks Movement of electrons layers of abstraction Shockley’s first transistor its greatgreat-… grandchild Silicon Dreams How does a machine think ? Algorithms our tasks How many problems am I facing ? program Programming Language p = 5*12; Java compile load p 5 mult p 12 Machine Instructions run computer’s tasks Movement of electrons layers of abstraction Shockley’s first transistor its greatgreat-… grandchild Abstract Art mygrid.drawRect(1,2,3,4,Color.magenta); 10 x 10 grid Assignment 2, Problem 4 Create the following “work”: g.addRect( g.addRect( g.addRect( g.addRect( … … … … … ); ); ); ); Why ? Science is about explaining and understanding data. Computer Science provides powerful tools to do this. simulation http://www.kingsu.ab.ca/~brian/proj/nbod2.html analysis How do we represent physical phenomena … ? How does each object affect others … ? N-body problem How many forces do we need to keep track of … ? Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.print("Hello World!"); System.out.println("How are you?"); } } System HMCSupport H are all basically the same. // start here HMCSupport.out.println(“harvey”); HMCSupport.out.print(“mu”); H.out.println(“dd”); H.out.print(“college”); H.p(“leg”); H.pl(“e”); Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { System.out.print("Hello World!"); System.out.println("How are you?"); } } System HMCSupport H are all basically the same. So, use H ! // start here HMCSupport.out.println(“harvey”); HMCSupport.out.print(“mu”); H.out.println(“dd”); H.out.print(“college”); H.p(“leg”); H.pl(“e”); Java baggage #5 -- Printing /* A Hello, World program */ class CS5App { public static void main(String[] args) { H.p("Hello World!"); H.pl("How are you?"); } } // start here goes to next line at end stays on same line at end H.pl(“harvey”); H.p(“mu”); goes to next line at end stays on same line at end H.pl(“dd”); H.p(“college”); \n puts a new line anywhere