Beruflich Dokumente
Kultur Dokumente
Chapter 1: Introduction
Aaron Bloomfield
Spring 2007
Lets begin
Goal
What is a computer?
So what is a computation?
Definition of computing:
Duh!
To determine by the use of a computer
To determine by mathematics, especially by numerical
methods: computed the tax due
Axiom
Stonehenge
Computer Size
ENIAC then
ENIAC today
Algorithms
10
11
Algorithms
What is an algorithm?
A step-by-step problem-solving procedure,
especially an established, recursive computational
procedure for solving a problem in a finite number
of steps
13
14
15
An optical illusion
16
Algorithm correctness
17
Incorrect algorithms
Can
Can
Can
Can
be wrong
be inefficient
never stop
have other problems as well
18
From http://en.for-ua.com/blog/2005/12/09/102028.html
19
20
22
23
It never halts
Note that humans know to not to spend forever performing the
algorithm
But computers do not!
25
Given an integer n
Keep track of an ongoing sum (starts at 0)
Repeat
Until n is zero
Our goal
27
Correct algorithms
Is this blue?
Definitely
Is this blue?
Definitely not
28
30
Carved watermelons
31
Programming a computer
32
33
ENIAC (1945)
Binary
100100010101001010101010
Assembly
FORTRAN (1954)
34
Programming Languages
BASIC
COBOL
Pascal
C (1972) by Dennis Ritchie
C++ (1985) by Bjarne Stroustrup
Java (1991) by James Gosling and others at Sun
Microsystems
35
Background
36
A bit is either a 1 or a 0
A byte is 8 bits:
01001010
As there are 8 bits per byte, each byte can hold 28=256 values
01001010 = 74
37
= Kibi (Ki)
= Mebi (Mi)
= Gibi (Gi)
= Tebi (Ti)
38
A music file on a CD
A movie clip
39
A marketing trick
= 250.06 Gigabytes
= 232.89 Gibibytes
Todays demotivators
41
42
Programming Task
43
HelloWorld.java
// Purpose: say hello!
public class HelloWorld {
public static void main(String[] args) {
System.out.println (Hello, world!");
}
}
One
application
statement
program
makes
up
is of
required
the
action
to of
have
method
a
A An
method
is a named
piece
code
that
performs
public
main()
staticorvoid
method named
main().
some
action
implements
a behavior
Method main() is part of class HelloWorld
44
Sample output
45
Program parts
46
Key words
Operators
Punctuation
Programmer-defined identifiers
Strict syntactic rules
47
Java Documentation
48
Key Words
public
class
static
void
String
Key words
Programming Languages
50
Lines vs Statements
51
Good commenting
Bad commenting
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
While at NCR, he was convicted for illegal anticompetitive sales practices (e.g. he used to have
people sell deliberately faulty cash registers, either
second-hand NCR or from competitors; soon after the
second-hand NCR or competitors cash register failed,
an NCR salesperson would arrive to sell them a brand
new NCR cash register). He was sentenced, along with
John H. Patterson (the owner of NCR), to one year of
imprisonment. Their conviction was unpopular with the
public, due to the efforts of Patterson and Watson to
help those affected by the 1913 Dayton, Ohio floods,
but efforts to have them pardoned by President Woodrow
Wilson were unsuccessful. However, the Court of
Appeals overturned the conviction on appeal in 1915,
on the grounds that important defense evidence should
have been admitted.
53
/*
* If the new process paused because it was
* swapped out, set the stack level to the last call
* to savu(u_ssav). This means that the return
* which is executed immediately after the call to aretu
* actually returns from the last routine which did
* the savu.
*
* You are not expected to understand this.
*/
if(rp->p_flag&SSWAP) {
rp->p_flag =& ~SSWAP;
aretu(u.u_ssav);
}
Source: http://www.tuhs.org/Archive/PDP-11/Trees/V6/usr/sys/ken/slp.c
54
Human stupidity
55
Programming overview
56
57
58
Software Engineering
in
the
designing,
writing,
testing,
debugging,
documenting,
modifying, and
maintaining.
59
Software Engineering
program specifications,
diagrams of screen output,
diagrams representing the program components and the
flow of data,
pseudocode,
examples of expected input and desired output.
60
Procedural programming
Object oriented programming
Data hiding
Code reusability
61
Computer Systems
62
Computer Systems
Hardware
Software
Operating systems
Application software
63
Input Devices
ALU
Control Unit
RAM
Output Devices
Input / Output
Devices
64
65
Instruction (input)
Arithmetic
Logic
Unit
Result (output)
Control
Unit
66
Fetch
Execute
Decode
67
contains:
is volatile
Secondary Storage
non-volatile
long-term memory
Examples
Hard drive
CD RW drive
DVD RAM drive
Compact Flash card
69
Input Devices
Keyboard
Mouse
Scanner
Digital camera
70
Output Devices
devices
Monitors
Printers
Operating Systems
Application Software
72
Operating Systems
DOS
Windows
Unix
Apple
73
Operating Systems
single user
DOS
Windows 95/98/ME
multi-user
Unix
BSD
Windows NT/2000/XP
OS/X
74
Application Software
Spreadsheets
Word processors
Accounting software
Tax software
Games
75