Unformatted text preview:

1Chapter 1 Chapter 1 --IntroductionIntroductionCh 1GoalsCh 1GoalsTo understand the To understand the activity of programmingactivity of programmingTo learn about the To learn about the architecturearchitectureof computersof computersTo learn about To learn about machine codemachine codeand and high level high level programming languagesprogramming languagesTo become familiar with your computingTo become familiar with your computingenvironmentenvironmentand yourand yourcompilercompilerTo To compile and runcompile and runyour first Java programyour first Java programTo To recognize syntax and logic errorsrecognize syntax and logic errors1.1 What is Programming?1.1 What is Programming?Computers are programmed to perform Computers are programmed to perform tasks tasks Different tasks = different programsDifferent tasks = different programsProgram Program Sequence of basic operations executed in Sequence of basic operations executed in succession succession Contains instruction sequences for all tasks it Contains instruction sequences for all tasks it can execute can execute How do we produce this program?How do we produce this program?1.2 Anatomy of a Computer1.2 Anatomy of a ComputerA computer is a machine that can do A computer is a machine that can do certain taskscertain tasksStores dataStores dataInteracts with devicesInteracts with devicesExecutes programsExecutes programsCPUCPUCentral Processing Unit (CPU) Central Processing Unit (CPU) --Heart of the Heart of the computercomputerMade of a chip (AMD, Intel, etc), millions of transistorsMade of a chip (AMD, Intel, etc), millions of transistorsExecutes instructions given by a programExecutes instructions given by a program1.2 Anatomy of a Computer1.2 Anatomy of a ComputerStorage Storage ––where data is keptwhere data is kept3 types 3 types ––primary, secondary, removableprimary, secondary, removable21.2 Anatomy of a Computer1.2 Anatomy of a ComputerComputers communicate through a Computers communicate through a networknetworkPeripheral devicesPeripheral devicesallow interaction with allow interaction with humanshumansSpeakers, screen, printer, scannerSpeakers, screen, printer, scannerRAM, Disks, peripherals connected to CPU RAM, Disks, peripherals connected to CPU via the via the busbusWhere is a program stored when it is not Where is a program stored when it is not currently running? currently running? Which part of the computer carries out Which part of the computer carries out arithmetic operations, such as addition arithmetic operations, such as addition and multiplication? and multiplication? 1.3 Translating Human1.3 Translating Human--Readable Readable Programs to Machine CodePrograms to Machine CodeThere are actually multiple levels upon which There are actually multiple levels upon which a program can be writtena program can be writtenMachine InstructionsMachine InstructionsAssembly Assembly High Level LanguageHigh Level LanguageMachine CodeMachine CodeThe most basic level of instructionsThe most basic level of instructionsEverything is represented with numbers (read Everything is represented with numbers (read in binary)in binary)Looks like this:Looks like this:00010101 00101000 (binary)00010101 00101000 (binary)21 40 (decimal)21 40 (decimal)This is the only language the CPU knowsThis is the only language the CPU knowsWhatWhat’’s the problem?s the problem?CPUs perform very primitive operations onlyCPUs perform very primitive operations onlyAdd, subtract, load from memoryAdd, subtract, load from memoryLeads to coding of several hundred lines to Leads to coding of several hundred lines to perform one simple operationperform one simple operationNot IntuitiveNot IntuitiveCan you look at 1000 numbers and tell what the Can you look at 1000 numbers and tell what the program is doing?program is doing?Each CPU uses a different set of instructionsEach CPU uses a different set of instructionsEach CPU translates different digits to mean Each CPU translates different digits to mean different thingsdifferent things3AssemblyAssemblyA slight step up from machineA slight step up from machineUses words and numbersUses words and numbersload 40load 40Still needs as many instructions as machine Still needs as many instructions as machine language, but is language, but is slightlyslightlyeasier to read.easier to read.High LevelHigh LevelHigh level is much more expressiveHigh level is much more expressiveOne statement is converted into several One statement is converted into several machine code instructionsmachine code instructionsThe conversion is done by the The conversion is done by the compilercompilerVery complicated and sophisticated, not the Very complicated and sophisticated, not the focus of this coursefocus of this course1.4 The Java Programming Language1.4 The Java Programming LanguageSimple Simple Safe Safe ––more secure, easier to catch more secure, easier to catch errorserrorsPlatformPlatform--independent ("write once, run independent ("write once, run anywhere") anywhere") ––operating system and operating system and architecturearchitectureRich library (packages)Rich library (packages)Designed for the Internet Designed for the Internet Java Virtual MachineJava Virtual MachineUnique to JavaUnique to JavaInstead of compiling for a particular Instead of compiling for a particular processor, Java compiles to a virtual processor, Java compiles to a virtual processor that is the same for every processor that is the same for every computercomputerLesson: The code is the same no matter Lesson: The code is the same no matter what computer you are on, so you donwhat computer you are on, so you don’’t t have to make a Mac version and a PC have to make a Mac version and a PC version, etc.version, etc.FlawsFlawsFully objectFully object--oriented nature can be oriented nature can be confusing to beginning programmersconfusing to beginning programmersMany revisions made Many revisions made ––make sure you make sure you update if you work from home to Java 5.0 update if you work from home to Java 5.0 (1.5)(1.5)Rich libraries Rich libraries So much to learnSo much to learn1.5 Becoming Familiar w/ your 1.5 Becoming Familiar w/ your ComputerComputerVery important to familiarize yourself with your Very important to familiarize yourself with your computercomputerUnderstand how to


View Full Document

UW-Madison CS 302 - Chapter 1 - Introduction

Download Chapter 1 - Introduction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chapter 1 - Introduction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 1 - Introduction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?