CS111 Lecture 1 Computer Science Computers Programming Aaron - - PDF document

cs111 lecture 1
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

7/2/12 1

Computer Science

CS111 Lecture 1

Computer Science Computers Programming

Aaron Stevens (azs@bu.edu)

2 July 2012

Computer Science

What You’ll Learn Today

  • What is computer science?
  • What are data and information?
  • What is a computer?
  • What are hardware and software?
  • What is computer programming?
slide-2
SLIDE 2

7/2/12 2

Computer Science

What is Computer Science?

Computer Science

CS is NOT Science!

The fundamental ideas of CS are:

  • Encoding Information
  • Algorithms
  • Protocols
  • Abstraction
slide-3
SLIDE 3

7/2/12 3

Computer Science

5

Flashlight Messaging

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?

Computer Science

Easy as ABC, 123

13 5 5 20 13 5 1 20 19 20 1 18 2 21 3 11 19

slide-4
SLIDE 4

7/2/12 4

Computer Science

Numbered Code

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.

Computer Science

Algorithm

An algorithm is a sequence of clear and precise step-by-step instructions for solving a problem in a finite amount of time.

slide-5
SLIDE 5

7/2/12 5

Computer Science

Encoding Algorithm

while more characters in message: c = next character in message n = number corresponding to that letter send n flashes pause done: no more flashes

Computer Science

Decoding Algorithm

while observing more flashes: n = count number of flashes until pause c = character corresponding to n flashes write down character c done

slide-6
SLIDE 6

7/2/12 6

Computer Science

Numbered Code: Good Enough?

What’s good about the numbered code? What’s not so good about it?

Computer Science

Protocols

A protocol is a set

  • f rules governing

the exchange or transmission of data between devices.

slide-7
SLIDE 7

7/2/12 7

Computer Science

Example Protocol: Morse Code

Invented by Samuel Morse for the telegraph in 1840s:

1.

A dash is equal to three dots

2.

The space between parts of the same letter is equal to one dot

3.

The space between two letters is equal to three dots

4.

The space between words is equal to seven dots

Example of telegraph key/sounder and Morse code: http://www.youtube.com/watch?v=Lki3jxNLVCI

Computer Science

Encoding Example: Braille

Each character is up to 6 dots. Each dot is either on or off.

Invented by Louis Braille (1809-1852).

slide-8
SLIDE 8

7/2/12 8

Computer Science

15 What are we looking at?

Computer Science

16

No, this is the matrix!

slide-9
SLIDE 9

7/2/12 9

Computer Science

17

What is this?

Computer Science

18

Your web browser decodes the data (1s and 0s) and renders the webpage.

slide-10
SLIDE 10

7/2/12 10

Computer Science

Abstraction

Abstraction is about hiding unnecessary details and retaining only the relevant information.

Computer Science

2

What is a computer, anyway? Give some examples:

What is a Computer?

A computer takes an input, applies a process, and produces an output.

slide-11
SLIDE 11

7/2/12 11

Computer Science

What is a Computer?

Computer Science

3

Analog Computers Information is processed directly in its indigenous form. Digital Computers Information processing and storage occurs using a symbolic representation of the data.

Analog or Digital

slide-12
SLIDE 12

7/2/12 12

Computer Science

Example: Analog Computer

The slide rule is a mechanical calculator. It works by aligning two logarithmic scales. Align the inputs, and read off the output.

Computer Science

24 3

Hardware

slide-13
SLIDE 13

7/2/12 13

Computer Science

Thinking Inside the Box

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.

Computer Science

Thinking Inside the Box

A computer motherboard A CPU Chip

Some typical components in 1993.

slide-14
SLIDE 14

7/2/12 14

Computer Science

Moore’s Law

Computing hardware will keep getting better, faster, cheaper for the rest of our lives.

Computer Science

Thinking Outside the Box

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)
slide-15
SLIDE 15

7/2/12 15

Computer Science

29

Early History of Computing

Joseph Jacquard (1801) Jacquard’s Loom read instructions from punched cards

Computer Science

3

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.

Programmability

slide-16
SLIDE 16

7/2/12 16

Computer Science

31 3

Software

Computer Science

30,000 Foot View of Software

slide-17
SLIDE 17

7/2/12 17

Computer Science

What is programming?

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

Computer Science

Hardware Instructions

The CPU does some low-level tasks, and each one is specified as a machine-language instruction.

slide-18
SLIDE 18

7/2/12 18

Computer Science

Machine Language Example

Computer Science

Machine Language

Characteristics of machine language:

  • Each instruction is an operation code and an operand,

expressed in binary.

  • Every processor type has its own set
  • f 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.

slide-19
SLIDE 19

7/2/12 19

Computer Science

Assembly Language

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”

Computer Science

The Assembly Process

Assembler A program that reads each of the instructions in mnemonic form and translates it into the machine-language equivalent.

slide-20
SLIDE 20

7/2/12 20

Computer Science

39

Example: Assembly Program

Computer Science

High-level Programming Languages

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?

slide-21
SLIDE 21

7/2/12 21

Computer Science

Source Code and Translation

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.

Computer Science

A compiler is a program that translates a high-level language program into machine code. The “compile step” is done all at once, in advance

  • f running the program, usually by the programmer

who wrote the high-level source code.

Compilers

Figure 8.1 Compilation process

slide-22
SLIDE 22

7/2/12 22

Computer Science

Most Popular Compiled Languages

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.

Computer Science

Interpreters

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.

slide-23
SLIDE 23

7/2/12 23

Computer Science

Most Popular Interpreted Languages

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

Computer Science

Portability

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.

slide-24
SLIDE 24

7/2/12 24

Computer Science

Compiled vs. Interpreted

Compiled Languages

  • Speed: tend to run faster than interpreted languages.
  • Portability: virtually none. To port to new CPU architecture, must re-

compile the source code and distribute new executable file.

Interpreted Languages

  • Speed: tend to run more slowly than compiled languages.
  • Portability: virtually seamless. Distribute source code directly, and it

will run on any suitable interpreter.

Computer Science

Compiled Language

Source Code (Program) Compiler Machine Code Program Inputs Running Program Outputs

A compiler takes source code, and produces executable machine code (stored in a file on disk). The machine code program is executed by the user. Advantage: speed at time of execution.

slide-25
SLIDE 25

7/2/12 25

Computer Science

Interpreted Language

Source Code (Program) Computer Running an Interpreter Inputs Outputs

An interpreter takes source code as input, and then compiles each

statement and executes it immediately. Advantage: portability

Computer Science

50

Java Technology

Introduced in 1996 and

became instantly popular for the World Wide Web.

  • Portability was of primary

importance.

Java is a hybrid language:

Java is both compiled and interpreted.

slide-26
SLIDE 26

7/2/12 26

Computer Science

Creating Java Programs

Java is compiled into a standard machine language called Java Bytecode, for the Java Virtual Machine. A software program called the Java Virtual Machine executes the Bytecode program by translating the JVM instructions into native instructions.

Computer Science

What You Learned Today

  • Computer Science is NOT a Science
  • Algorithms, Encoding Information, Protocols, and

Abstraction.

  • Data vs. Information
  • Computers
  • Hardware/Software
  • Computer Programming
  • Java
slide-27
SLIDE 27

7/2/12 27

Computer Science

Setting up a CS Account

Computer Science

Announcements and To Do List

  • Lab 00: Sign up for lab account (right now)
  • Today: lab 01
  • Read chapter 1 of the book
  • Tuesday: meet at teaching lab, EMA 304