CS 51 Intro to CS Art Lee September 2, 2014
Announcements Course web page at: http://www.cmc.edu/pages/faculty/alee/cs51/ Homework/Lab assignment submission on Sakai: https://sakai.claremont.edu/portal/site/cx_mtg_79055 Survey form: See Announcements on the course web Reading assignment for this week: Chapter 1 of Reges Emacs don t worry about it yet Take a break around 10:15am 2
Goals Introduction to computer science Learn how to solve a problem by: defining the problem developing a solution (algorithm) implementing the solution by writing a computer program testing and fixing the programming solution Learn to program in Java 3
Philosophy Welcome all majors and backgrounds! Provide a healthy mix of the practical and theory Develop problem solving skills 4
Still deciding? Prerequisites: none Known as "CS 51" - the first course in the introduction to computer science sequence For non-cs majors, this course is an excellent way to get an introduction to what computer science is all about and learn how to program; however you may consider taking CS 40 (Computing for the Web) if you are not intending to pursue further study in CS beyond the first course. For CS majors, this course is a launching point into the computer science sequence/major 5
Take this course if you... like solving (tricky) problems like building things (will) work with large data sets are curious about how Facebook, Google, etc. work have never written a computer program before are shopping around for a major CS 51 is a good indicator of who will enjoy and succeed in CS 6
How to succeed in this class Attend class Not all information is in my lecture notes or in the book I draw a lot on the board Take the homework and lab assignments seriously Start early Homework will take longer than you think Read the reading assignments and review the lecture notes and example code Learning to read code takes practice Ask questions if confused. Don't stay confused. 7
Textbook "Building Java Programs: A Back To Basics Approach" by Reges and Stepp I will post links to other references as we go 8
Homework There will be about one assignment per week Homework assignments will be posted to the course web You will turn in homework on Sakai Respect the homework assignments! Designed to challenge you in applying what you've learned so far Start early! Programming projects almost always take longer than expected Study the solutions and compare with your own work Read "How To Approach This Class" in the syllabus for detailed suggestions. 9
Lab There are two lab sections: Section 1: Tuesday, 8:00-8:50am, Room TBD Section 2: Tuesday, 11:00-11:50am, Room TBD You may attend either one Attending labs is optional but the lab assignments are mandatory Lab assignments will be posted to the course web site Turn in lab assignments on Sakai 10
Cooperation vs. cheating Cooperation (talking over problems) is a good way to learn and is encouraged Copying is not allowed on homework or exams no matter the source (written or verbal). When you submit your homework or tests, you are pledging that the work is your own and you have not copied it. You are also pledging that you have not allowed others to copy it. For more details on my policy on this matter, refer to the one in the course syllabus 11
Grading See the "Grading" section of the course web site for details Also browse the class web to see other info that I am not going over in class 12
What is computer science? A definition from the Internet: Computer science is the systematic study of computing systems and computation. The body of knowledge resulting from this discipline contains theories for understanding computing systems and methods; design methodology, algorithms, and tools; methods for the testing of concepts; methods of analysis and verification; and knowledge representation and implementation. 13
For us, we will Learn how to begin with a problem statement and systematically design a computer program that solves the problem Write programs Using a programming language, Java in particular While interacting with a computer through an operating system such as DOS, Windows, or Unix/Linux/Mac OS X Execute the programs Using a compiler and an interpreter in the case of Java While trying to understand what is happening in each step of the process 14
So,... We will learn how to write a program that solves a given problem We will learn enough of the programming language Java to write such programs Along the way we will learn many fundamental concepts in computer science that make all these possible We will use a Java compiler (and a Java bytecode interpreter) as part of a programming environment called jgrasp or Eclipse We will use some hardware, whatever computer that you happen to be using We will learn the entire lifecycle of program development: from a concept in your head to a program to a piece of compiled code to electrical signals that run through the wires (abstracted views on the low-level elements of course) 15
So,... (cont.) At the end of the semester you will be comfortable enough (?) to write Java programs that solve fairly complex problems You will have hopefully learned enough about computer science by then and be able to decide whether or not CS is for you to pursue as a discipline, if you are not sure of that yet In any event the CS concepts/fundamentals that you learn in the course will help you understand the concept of computing and some of the key technologies that underlie the real world computing systems that you see now and you will see in the future 16
What do computer scientists do? In general, computer scientists deal with many things, some of which include: Build computers Build operating systems Programming languages and compilers Theory of computation Algorithms and data structures Parallel systems, distributed systems Web systems including social networking systems Software engineering Computer architecture Databases 17
(Cont.) Artificial intelligence Computer graphics Human-Computer Interaction Natural language processing Speech recognition Computer vision Cryptography Computer security Networking Scientific computing Biocomputing... 18
The big picture of a computer Hardware CPU Memory I/O devices Disk Bus Software Operating system (DOS, Windows, Unix/OSX) Applications Web apps Mobile apps Hello.java program that we will see soon Java compiler (the 'javac' command that we will see) Firefox, Chrome, Facebook, Tic Tac Toe, etc. 19
What is a program? A sequence of instructions that specifies how to perform a computational task see Hello.java What is the computational task that we perform in this example? 20
What is programming? Programming is the process of writing a program using a programming language Also referred to as "writing code" or simply "coding Program execution: the act of carrying out the instructions contained in a program A computer is pretty dumb though Consequently, you have to give super clear and precise instructions A computer will happily do the same thing forever (on an infinite loop) if you tell it to do so, even if you didn't mean to! Learning to program is just like learning a "natural" language like Spanish. You have to LEARN the: Syntax: the words and rules in the language Semantics: the meaning of each word or phrase in the language 21
What is a programming language? A systematic set of rules used to describe computations in a format that is editable by humans A "formal" language as opposed to a "natural" language Java (cf. C, C++, C#, Python, Objective-C, Javascript, etc.) High-level languages Low-level languages 22
Computer instructions: machine language Binary instruction (1's and 0's) Most instructions just move data around or perform simple arithmetic operations Binary programming is ready hard and tedious but early programmers used to this! Example: on Intel x86 processors, 1011000001100001 means to copy a 97 to a particular register 23
Computer instructions: assembly language Symbolic (meaningful) names for binary instructions and memory More readable Feasible for programmers to use Example: ADD DR, SR1, SR2 ; DR <- (SR1) + (SR2) LD DR, LABEL ; DR <= Mem[LABEL] LDR DR, BaseR, Offset ; DR <- Mem[BaseR + Offset] STI SR, LABEL ; Mem[Mem[LABEL]] <= SR 24
Computer instructions: high-level language Symbolic names for assembly instructions and memory Symbolic names for basic operations such as conditionals and looping Language constructs for abstracting a set of instructions Close to "natural" languages - close to being readable! Example: print("welcome to CS!"); y = a * x * x + b * x + c; 25
Why use a high-level language? Conciseness high-level programming languages allow us to perform common operations in a concise and readable fashion Maintainability Modifying and maintaining code is much easier when the code is concise and easy to read (as compared to lengthy and difficult to read assembly or binary code) Portability Different CPU's accept different binary instructions Writing in a high-level language allows code to be translated or "compiled" into a platform-specific binary code Allows your code to be "ported" to another platform 26
Why Java? Relatively simple simpler than C++ General-purpose, object-oriented Platform independent (Mac, Windows,...) Java has good support Widely used http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 27
Java s roots C was developed in the early 1970 s C was designed to be small, fast, with little built in safety C++ was developed in the late 1970 s C++ is a superset of C and extends C to include object-oriented concepts Java borrowed from C/C++ but more concerned about safety and productivity at the cost of some speed Java's creator James Gosling has described Java as "C++ without guns, knives, and clubs Designed to be used in the Internet era 28
Demo: some examples of what we will do this semester: Hello.java Ttt.java Jukebox.java 29
Do these before next class Send me your survey form Read the course syllabus Read the course web Start reading Chapter 1 of Reges (will try to complete Ch 1 on Thursday) For Java compiler installation, you may wait until the first lab session 30
Two pieces of advice Attend every class! DO NOT GET BEHIND!! 31