560 likes | 684 Views
Introduction to Computer Science and Programming. The Computer. To understand at a conceptual level: What is a computer?. The Computer. WHICH IS SMARTER?. The Computer. WHICH IS SMARTER? A Computer. The Computer. WHICH IS SMARTER? A Computer - OR A Toaster.
E N D
The Computer • To understand at a conceptual level: • What is a computer?
The Computer • WHICH IS SMARTER?
The Computer • WHICH IS SMARTER? A Computer
The Computer • WHICH IS SMARTER? A Computer - OR A Toaster
The Computer • To understand at a conceptual level: • What is a computer?-nothing but a box filled with wires and lights
The Computer • To understand at a conceptual level: • What is a computer?-nothing but a box filled with wires and lights - it needs software to be anything more than this.- software gives the box the ‘intelligence’
The Computer • To understand at a conceptual level: • What is a computer?- two branches of Computer ScienceSOFTWARE--------------------- hardware
The Computer • What does the computer understand?How does a computer ‘see’ the world? (let’s go inside the mind of a computer)
The Computer • What does the computer understand?ON / OFFHigh voltage / Low (no, absence of) voltageHumans represent these two ‘states’ asone (1) and zero (0)
The Computer • What does the computer understand?One (1) and Zero (0)Two statesBinary Numerical System (base 2)We use decimal (base 10) numerical system - why?
The Computer • What does the computer understand?Decimal: 0,1,2,3,4,5,6,7,8,9 (repeat) Binary: 0, 1 (repeat)
The Computer • What does the computer understand?Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (repeat) 10,11,12,13,14,15,16,17,18,19 (repeat) 20,21,22,23,24,25,26,27,28,29 …. Binary: 0, 1 (repeat) 10, 11 (repeat) 100,101,110,111 (repeat) 1000,1001,1010,1011,1100,1101,1111 (repeat)
The Computer • What does the computer understand?Direct translation of systems:BINARY DECIMAL 0 = 0 1 = 1 10 = 2 11 = 3100 = 4101 = 5110 = 6111 = 7
The Computer • What does the computer understand?Direct translation of systems:VERY %$*!@# CONFUSING !!!!!Do not think of binary as ‘numbers’Think of binary as ‘symbols’ • Do not look at 1001 and see ‘one thousand and one’see this as the ‘symbol for ‘nine’
The Computer • What does the computer understand?Direct translation of systems:each position in a number is the base of the numberDecimal: 2459 2 is in the thousands position 4 is in the hundreds position 5 is in the tens position 9 is in the ones position1000100101 2 4 5 9 (2 x 1000) + (4 x 100) + (5 x 10) + (9 x 1)
The Computer • What does the computer understand?Direct translation of systems:each position in a number is the base of the numberBinary: 11011 1 is in the sixteenth position 1 is in the eighths position 0 is in the fourths position 1 is in the twos position 1 is in the ones position168421 1 1 0 1 1 (1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (1 x 1) = 27 (decimal)
The Computer • What does the computer understand?Binary Numbers: - So What ???????
The Computer • What does the computer understand?Binary Numbers: - So What ??????? - humans need a method of telling the computer what to do - some way to ‘communicate’ with the machine - otherwise it is just lights and wires in a box…
The Computer • What does the computer understand?Binary Numbers: - we use numbers to ‘communicate’ with the machine- a computer is limited to understanding only binary (on / off)- so, we use binary
The Computer • What does the computer understand?Binary Numbers: break binary (on / off ) into units. one binary is a BIT a BIT is either a 1 or a 0-> 1 eight BITs strung together is a BYTE a BYTE is a combination of eight 1’s and 0’s-> 1100 1001
The Computer • What does the computer understand?Binary Numbers: byte = 8 bits kilobyte = 1,000 bytes (or 1,024 bytes) megabyte = 1,000,000 bytes or 1,048,576 bytes or 1,024,000 bytes gigabyte = 1,000,000,000 bytes or 1,072,436,586 bytes or 1,024,000,000 bytes terabyte = 1,000,000,000,000 bytes…
The Computer • What does the computer understand?Binary Numbers: byte = (one alphabetic character)kilobyte = one third (1/3) of a pagemegabyte = one half (1/2) average size bookgigabyte = 500 booksterabyte = 500,000 books… next we will see what this has to do with programming
The Computer • So, we have these machinesWe know they only understand on / off (0 / 1)How do we it get the machines to do anything • Answer: talk to them in their language: 11010101001001 - this is known as machine language - (the lowest level language) • - a machine may be designed to take each byte, break it in half (called a nybble – or four bits) and process the ones and zeros - an instruction to the computer could look like:10110000 01100010
The Computer • - an instruction to the computer could look like:10110000 01100010- the next line could be:10010000 10111011These are actual machine instructions telling the computer to remember the number 97 and then to add 35 to itself and remember that number.
The Computer - this was fine but awful tedious, awful hard and just plain awful- a better way had to be found.- assembly language was created it associated certain numeric instruction to near English mnemonics like MOV for move and ADD for add10110100 01111101 becomes MOV a1,61h 10012000 10010111 becomes ADD a1,23hA different program (an assembler) inside the computer assembles (translates) the MOV back to 0100, a1 becomes the address 0110 and 111101 is 61h.
The Computer - okay but still awful tedious, awful hard and just plain awful- a yet better way had to be found.- higher level languages where created Fortran and COBOL and C MOV a1,61h becomes x := 97 ADD a1,23h becomes x:= x + 35A different program (a compiler) inside the computer compiles (translates) the := back to 0100, x becomes the address a1 and 111101 is 97 (61 in hex).
The Computer - BUT !!!!!- these languages could all be machine dependent- machine A may break instructions down into nybbles (4 bits) but machine B may keep instructions at one byte (8 bits).- the compiler made for Machine A will cause errors in Machine B because when it translates four bits only the computer will be expecting eight.- need a machine independent way of making programs.- but why would machines have different ways of using ones and zeros? - answer is in the history of how computers came to be created.
The Computer • How long have ‘computers’ been around? • Imagine the world without computers without the internet without IM without games without graphics (or George Lucas) without ????? • What is the ‘origin’ of the word (as it applies to this)?
The Computer – A Brief History • First ‘computer’ -ABACUS about 2700 BC
The Computer – A Brief History • Next Stage: ’ -the Differential Analyzer around 1927 (analog computing device)
The Computer – A Brief History • Along comes World War Twoneed to ‘crunch’ some serious numbers - cannon trajectories - Enigmaaround 1942 (electronic computing device: Colossus)
The Computer – A Brief History • Use of the Vacuum Tube (br. Valve) a tube can be used to create a ‘gate’ (or circuit) gates can be tied together to create a processing unit
The Computer – A Brief History • Put all these tubes in a sequence and you get a computerENIAC (1944) • around 1942 (electronic programmable computing device)
The Computer – A Brief History • Programming the ENIAC- bootstrapping the computer
The Computer – A Brief History • The first computer ‘bug’ Grace Hooper (1947) • - notation by one of the creators of COBOL computer language
The Computer – A Brief History • Next came the invention of the transistor (1947)Notably maybe the single greatest invention of the 20th centuryOriginally designed to be used in airborne radar- eventually replaced tubes in everything from radios to x-ray machines- ushered in the ‘electronic’ age
The Computer – A Brief History • The transistor removed the big roadblock from larger and more powerful computers (heat) (size) (weight) • Transistors could be combined on a silicon ‘wafer’ to create an integrated circuit • Integrated Circuits allowed the building of ‘modern’ digital devices like the IBM 360. (1960’s)
The Computer – A Brief History • Now computers are the domain of the ‘Business World’Computers are great as tabular machines- used to collate and store data- the general public only knows computers through tv and movies
The Computer – A Brief History • Access to computers is very limited and restricted. • Business and University have the main availability. • Input was still laborious - punch cards - batch jobs
The Computer – A Brief History • Then came along the Intel 8800 microchip(originally designed for calculators) • Used to make the first home computer (January, 1975) it started a revolution
The Computer – A Brief History • Overwhelming response to the Altair led to three major events (2 and half really) • Creation of Microsoft (1975) • Creation of the Apple II (1977) • (which led to the) Creation of the IBM PC (1981)
The Computer – A Brief History • Bringing us to concept of Moore’s Law • “the processing power of the computer will double every 2 years” 1965
The Computer – A Brief History • Evolution in Computers - started with external wires - moved to punch cards - introduction of CRT Monitors (direct input via typing) - introduction of Personal Computers - but: what to do with them? - software for home and business – and games (text based) - creation of sound cards - creation of video cards - faster, smaller more powerful equipment - laptops - computers become ubiquitous – are found everywhere… - Advanced Research Projects Agency, known as ARPA creates the arpanet incase of nuclear war - internet - World Wide Web - on August 29, 1997 (or April 21, 2011) skynet becomes self aware
A Traditional Computer Central Processing Unit Memory Input Devices Output Devices Secondary Memory
A Traditional Computer • Central Processing Unit (CPU)(also known as the processor) • Executes instructions • Main Memory (also known as RAM) • Internal storage that holds the programs (instructions and data) currently being executed by the CPU • Made up of electronic “on-off” switches,each of which represents 0 or 1 and iscalled a bit(binary digit) • It’s volatile(information stored in it is not retained when power is turned off)
A Traditional Computer • Secondary Memory: hard disks, CDs, DVDs, USB sticks • Provide long-term (persistent) storage for programs and other information • Organized as files,each of which has a file name and a folder (directory)that contains it. • Input/Output (I/O) units: keyboard, mouse, screen, printer, webcam, etc. • Used for communicating information from the user to the computer and vice versa
What is Programming ? • Programmingis the process of creating detailed instructionsthat a computer can execute to accomplish some task:a program • It is much like: • Writing a recipe for your favourite dish • Giving someone directions to your house • Making a robot do what you want
What is a program ? • Programs consist of • Instructions to perform a task • Data values used in performing the task • Programs are written in a language that a computer can (eventually) understand … public class HelloWorld { public static void main(String[ ] args) { System.out.println("Hello World!"); } }
High Level Languages • Programmers usually write programs in high-level languages • Examples: • Java, C, C++, C#, Visual Basic, Python, Scheme, Lisp, Pascal, Fortran, etc. etc. • People-oriented: created to make it easier for programmers to write programs that perform complicated tasks • Machine independent: a program in a high level language is not written for any particular kind of computer (Intel, Mac, etc.)