Lecture Outline Principles of Computer What is a computer? Science I What is computer science? Course mechanics Prof. Nadeem Abdul Hamid Hardware & programming overview CSC 120 – Fall 2005 Lecture Unit 1 - Introduction Compiling & running Java programs Binary numbers 1 CSC120 — Berry College — Fall 2005 2 Portions based on Python Programming: An Introduction to Computer Science by John Zelle What is a ‘computer’? Modern Computers What have you used a ‘computer’ for? “A machine (?) that stores and manipulates information under the control of a Writing a paper… balancing checkbook… playing changeable program.” games… Two key elements to definition: Computers also used to… Device for manipulating information Predict the weather… design airplanes… make Calculators, gas pumps also manipulate info… but movies… run businesses… perform financial these are built to only perform single, specific tasks transactions… control factories… Operate under control of a changeable program How can one device perform so many tasks? Can provide step-by-step instructions to a computer telling it what to do What exactly is a ‘computer’? By changing the computer program , can get the computer to perform different tasks 3 4 A Universal Machine Programming Every computer is a machine for executing Software (programs) control hardware (the (carrying out) programs physical machine) Many different types of computers Building software = programming Macintoshes, PCs… Challenging Thousands of other kinds of computers, real and See the big picture while paying attention to small details, but… theoretical Anyone can learn to program Remarkable discovery of computer science: Become a more intelligent user of computers All different types of computers have same power Fun With suitable programming, each computer can Career basically do all the things any other can 5 6 1
Computer Science (CS) Role of Algorithms in CS Is NOT “the study of computers” Dijkstra: computers are to CS as telescopes are to astronomy Fundamental question of CS: What can be computed? Computers can carry out any process we describe So, what processes can be described in order to solve problems? Algorithm : Step-by-step process to solve a problem 7 8 Algorithms in CS Subareas of CS Architecture hardware-software interface Step-by-step process that solves a problem Artificial Intelligence thinking machines More precise than a recipe Eventually has to stop with an answer Computational Geometry theory of animation, 3-D models General description of a process rather than specific to a Graphics from Windows to Hollywood computer or programming language Operating Systems run the machine Scientific Computing weather, hearts Areas of CS discipline span Theory (mathematics) Software Engineering peopleware Experimentation (science) Theoretical CS analyze algorithms, models Design (engineering) Many other subdisciplines… networking, numerical and symbolic computation, bioinformatics, databases and information retrieval, web and multimedia design, security, human-computer interaction… 9 10 Assignments Course Mechanics Weekly lab/homeworks Syllabus, lectures notes, assignments, etc. on web page Due on Wednesdays http://fsweb.berry.edu/academic/mans/nhamid/classes/cs120/05fall Class meetings Programming Projects Lectures: Mon/Wed/Fri, 10-10:50AM, SCI 107 Labs: Thurs, 3–5PM, SCI 228 DON’T WAIT UNTIL DAY/NIGHT BEFORE TO Contact START WORKING ON ASSIGNMENTS Office: SCI 354B — Phone: 368-5632 No late work accepted, without formal excuse/prior Email: nadeem@acm.org arrangement Office Hours You will NOT be able to complete the programming Mon — 11AM–12:30PM assignments in one night Tue — 11AM–12:30PM Wed — 11AM–12:30PM and 2–4PM Send email if you have a problem (attached Thu — 10AM–12:30PM and 2-3PM relevant files and say where you’re stuck) (or by appointment…) 11 12 2
Programming Assignments Materials and Resources Completed programs must ‘work’!!! Textbook: Java Concepts, 4th Edition , Cay Horstmann Compile and run (will learn what that means later) Online course website: Check regularly If you leave programming assignments to Software (in computer lab SCI 228) the last minute, you will run a major risk of Java 5.0 (JDK): http://java.sun.com/j2se/1.5.0/download.jsp having incomplete work Compiler; runtime system DrJava: http://www.drjava.org Editor; development environment 13 14 Grading and Evaluation Hardware Basics Class participation and attendance (10%) Lab participation and attendance (10%) Assignments/Projects (40%) Exams (40%) Tentative dates: First exam: Friday, September 23, 2005 Second exam: Friday, October 28, 2005 Final exam: ??? Policies (see syllabus) Attendance Academic integrity Late work Disabilities 15 16 Central Processing Unit (CPU) Memory Heart and brain of the machine Stores programs and data Chip composed of transistors, wiring CPU can only directly access info. in main Two primary components memory or primary storage (RAM- random Arithmetic/Logic Unit (ALU) performs arithmetic access memory) and logical operations Relatively expensive Control Unit controls the order in which Volatile (loses data when no power) instructions in the program are executed Secondary storage- more permanent Hard disk Floppy, CD, DVD, tape, … Pentium (left) and PowerPC G3 chips 17 18 3
RAM - Main Memory Peripheral Devices Input Devices Ordered sequence of storage cells keyboard Each holds one piece (a ‘word’) of data mouse ‘Data’ is a sequence of bits (on/off - 0/1) Output Devices 8 bits = 1 byte printer video display LCD screen Each memory cell has a unique address Auxiliary Storage (integer number) disk drive CD-ROM drive DVD-ROM drive 19 20 Fetch-Execute Cycle Machine Code How the CPU operates Instructions/operations that CPU ‘understands’ Fetch the next instruction Different vendors (Intel, Sun, IBM) use Decode the instruction into control signals different sets of machine instructions Get data if needed (from memory) Execute the instruction Extremely primitive Input Main Output CPU Encoded as (binary) numbers devices Memory devices ALU, registers Bus 21 22 Programming Languages High-level Languages Could we use English to give instructions to a Designed to be used and understood by humans computer? C, C++, Java, Perl, Scheme, BASIC, … “I saw the man in the park with the telescope.” All have well-defined, unambiguous syntax and Who had the telescope? Who was in the park? semantics ‘Natural languages’ are full of ambiguity and imprecision Made up for by lots of redundancy and shared human knowledge Problem: Computer scientists design precise notations for Humans write code (programs) in high-level languages expressing instructions/statements: programming Computers only ‘understand’ machine language (0’s, 1’s) languages Programming languages have structures with Compiler : Program that translates programs from high-level language to machine code Precise form ( syntax ) Precise meaning ( semantics ) 23 24 4
Caveats Java Programming Language Programs we write in this course will not be fancy Benefits Today’s sophisticated programs/games built by teams of highly skilled programmers, artists, other professionals Simple (compared to C++) Java language Safe (security features prevent many ‘bad’ things) Was designed for professionals, not students Platform-independent (‘write once, run anywhere’) Evolving - features change with different versions (we’ll be Rich library (packages) using 5.0) Cannot learn all Java in one semester Lots of code already written for you to do lots of stuff In fact, no one can hope to learn entire Java library in a Designed for Internet (applets) lifetime… Goal of this course: Learn how to think about problem solving and expressing precise solutions using a programming language 25 26 Writing a Program Software Life Cycle Specify the problem remove ambiguities identify constraints Problem-solving and design Develop algorithms, design Implementation classes, design software architecture Problem-solving phase Maintenance Implement program Algorithm revisit design test, code, debug Problem revisit design Documentation, testing, maintenance of program Code From ideas to electrons No shortcuts! Implementation phase 27 28 Writing and Compiling a Java Algorithms and Programs Program Using DrJava IDE = Integrated Development Environment Algorithm instructions for solving a problem in a finite amount of time using a finite amount of data expressed in a precise, but general, way (using English?), independent of type of computer Program an algorithm written for a computer using a particular computer/programming language 29 30 5
Recommend
More recommend