cs111 lecture 1
play

CS111 Lecture 1 Computer Science Computers Programming Aaron - PDF document

7/2/12 CS111 Lecture 1 Computer Science Computers Programming Aaron Stevens (azs@bu.edu) 2 July 2012 Computer Science What Youll Learn Today Computer Science What is computer science? What are data and information? What is a


  1. 7/2/12 CS111 Lecture 1 Computer Science Computers Programming Aaron Stevens (azs@bu.edu) 2 July 2012 Computer Science What You’ll Learn Today Computer Science  What is computer science?  What are data and information?  What is a computer?  What are hardware and software?  What is computer programming? 1

  2. 7/2/12 What is Computer Science? Computer Science CS is NOT Science! Computer Science The fundamental ideas of CS are:  Encoding Information  Algorithms  Protocols  Abstraction 2

  3. 7/2/12 Flashlight Messaging Computer Science Imagine you are 10 years old, in 1980... Your best friend lives next door. You want to send messages at night. You each have a flashlight. What do you do? 5 Easy as ABC, 123 Computer Science 13 5 5 20 13 5 1 20 19 20 1 18 2 21 3 11 19 3

  4. 7/2/12 Numbered Code Computer Science Replace each character with a number… Coded Message Example: 13 5 5 20 13 5 1 20 19 20 1 18 2 21 3 11 19 Encoding is about converting data into a coded form. Decoding is about converting from coded to normal form. Algorithm Computer Science An algorithm is a sequence of clear and precise step-by-step instructions for solving a problem in a finite amount of time. 4

  5. 7/2/12 Encoding Algorithm Computer Science while more characters in message: c = next character in message n = number corresponding to that letter send n flashes pause done: no more flashes Decoding Algorithm Computer Science while observing more flashes: n = count number of flashes until pause c = character corresponding to n flashes write down character c done 5

  6. 7/2/12 Numbered Code: Good Enough? Computer Science What’s good about the numbered code? What’s not so good about it? Protocols Computer Science A protocol is a set of rules governing the exchange or transmission of data between devices. 6

  7. 7/2/12 Example Protocol: Morse Code Computer Science Invented by Samuel Morse for the telegraph in 1840s: A dash is equal to three dots 1. The space between parts of the 2. same letter is equal to one dot The space between two letters is 3. equal to three dots The space between words is 4. equal to seven dots Example of telegraph key/sounder and Morse code: http://www.youtube.com/watch?v=Lki3jxNLVCI Encoding Example: Braille Computer Science Each character is up to 6 dots. Each dot is either on or off. Invented by Louis Braille (1809-1852). 7

  8. 7/2/12 What are we looking at? Computer Science 15 No, this is the matrix! Computer Science 16 8

  9. 7/2/12 What is this? Computer Science 17 Computer Science Your web browser decodes the data (1s and 0s) and renders the webpage. 18 9

  10. 7/2/12 Abstraction Computer Science Abstraction is about hiding unnecessary details and retaining only the relevant information. What is a Computer? Computer Science What is a computer, anyway? A computer takes an input, applies a process, and produces an output. Give some examples: 2 10

  11. 7/2/12 What is a Computer? Computer Science Analog or Digital Computer Science Analog Computers Information is processed directly in its indigenous form. Digital Computers Information processing and storage occurs using a symbolic representation of the data. 3 11

  12. 7/2/12 Example: Analog Computer Computer Science The slide rule is a mechanical calculator. It works by aligning two logarithmic scales. Align the inputs, and read off the output. Hardware Computer Science 24 3 12

  13. 7/2/12 Thinking Inside the Box Computer Science A computer ’ s internals are typically hidden from the user. They consist of:  Integrated circuit chips such as the central processing unit (CPU), memory circuits, and device controllers.  Integrated devices for storage (e.g. hard disk), communication (e.g. network adapter, Bluetooth).  Greenboard and connecting wires. Thinking Inside the Box Computer Science A computer motherboard A CPU Chip Some typical components in 1993. 13

  14. 7/2/12 Moore ’ s Law Computer Science Computing hardware will keep getting better, faster, cheaper for the rest of our lives. Thinking Outside the Box Computer Science The stuff that connects to the computer ’ s box are called peripherals. These include:  Input devices (e.g. keyboard, mouse)  Output devices (e.g. video displays, printers)  Storage devices (e.g. hard drive, USB key) 14

  15. 7/2/12 Early History of Computing Computer Science Joseph Jacquard (1801) Jacquard’s Loom read instructions from punched cards 29 Programmability Computer Science What tricks does your computer do? – Web browsing, email, instant messenger – Play games – Watch movies, organize photos – Word processing, spreadsheets, database Programmability is the ability to give a general- purpose computer instructions so that it can perform new tasks. 3 15

  16. 7/2/12 Software Computer Science 31 3 30,000 Foot View of Software Computer Science 16

  17. 7/2/12 What is programming? Computer Science Programming is the process of analyzing a problem, designing a solution, and encoding that solution into the form (syntax) and meaning (semantics) the computer expects. Layers of abstraction: High Level Programming Languages Assembly Language Machine Language Computer Hardware Hardware Instructions Computer Science The CPU does some low-level tasks, and each one is specified as a machine-language instruction. 17

  18. 7/2/12 Machine Language Example Computer Science Machine Language Computer Science Characteristics of machine language:  Each instruction is an operation code and an operand, expressed in binary.  Every processor type has its own set of specific machine instructions.  The relationship between the processor type and the instructions it can carry out is completely integrated.  Each machine-language instruction does only one very low-level task. 18

  19. 7/2/12 Assembly Language Computer Science Assembly language A language that uses mnemonic codes to represent machine- language instructions. Mnemonic code examples:  LOADA means “ load value into accumulator ”  ADDA means “ add value into accumulator ”  STOREA means “ store value from accumulator ” The Assembly Process Computer Science Assembler A program that reads each of the instructions in mnemonic form and translates it into the machine-language equivalent. 19

  20. 7/2/12 Example: Assembly Program Computer Science 39 High-level Programming Languages Computer Science High-level language A language that provides a richer (more English like) set of instructions. Example: int a = 2; int b = 5; int total = a + b; System.out.println(total); How can the computer understand this kind of language? 20

  21. 7/2/12 Source Code and Translation Computer Science A high-level language program is written in a plain-text format called source code. There are 2 approaches to translating source code into the machine-level instructions that the computer can execute.  Typically, a high-level language is either compiled OR interpreted, not both. Compilers Computer Science A compiler is a program that translates a high-level language program into machine code. Figure 8.1 Compilation process The “ compile step ” is done all at once, in advance of running the program, usually by the programmer who wrote the high-level source code. 21

  22. 7/2/12 Most Popular Compiled Languages Computer Science Fortran, 1952  IBM, Numeric and Scientific Computing  Still in use in biology dept at BU! Pascal, 1970  Developed for teaching students structured Programming  Early Macintosh operating system, Apple Lisa written in Pascal C, 1972  Ritchie and Kernigan, AT&T Bell Laboratories Developed for system software, UNIX  C++, 1979  Bjarne Stroustrup, AT&T Bell Laboratories Backwards compatible with C, and objects  ADA, 1983  Department of Defense  1970s: concern that DoD had too many programming languages  By 1996: down to only 37 C and C++ together have been the most popular compiled languages with the most programmers and applications. Interpreters Computer Science An interpreter is a program that translates and executes the program ’ s source code statements in sequence.  An interpreter translates a statement and then immediately executes the statement.**  Interpreters can be viewed as simulators. ** Whereas an assembler or compiler produces machine code as output; executing the code is a separate step. 22

  23. 7/2/12 Most Popular Interpreted Languages Computer Science BASIC, 1963  Beginner ’ s All-purposes Special Instruction Code  Kemeny and Kurtz, Dartmouth College  Invented for non-science and non-mathematics users. Perl, 1987  Invented by Larry Wall of Unisys Corporation  Regular Expression engine for text processing Visual Basic/Visual Basic .NET, 1991  Invented at Microsoft, a GUI scripting language  Extremely popular; huge installed business application base Python, 1991  Guido van Rossum, researcher at BDFL in the Netherlands  Minimalist semantics  Named after Monty Python Portability Computer Science Portability is the ability of a program written on one machine to be run on different machines. Compiler portability A program gets compiled for a particular CPU instruction set, and can only be run on a computer with that type of CPU. Source code portability A program in an interpreted language can be distributed and run (interpreted) on any machine that has the appropriate interpreter. 23

Recommend


More recommend