This preview shows pages 1–3. Sign up to view the full content.
1.1
Your First Program
2
Why Programming?
Idealized computer.
"Please simulate the motion of a system of N
heavenly bodies, subject to Newton's laws of motion and gravity."
Prepackaged software solutions.
Great, if it does exactly what you need.
Computer programming.
Art of making a computer do what
you
want.
Ada Lovelace
Analytic Engine
3
Languages
Machine languages.
Tedious and errorprone.
Natural languages.
Ambiguous and hard for computer to parse.
Highlevel programming languages.
Acceptable tradeoff.
[ real newspaper headlines, compiled by Rich Pattis ]
Kids Make Nutritious Snacks.
Red Tape Holds Up New Bridge.
Police Squad Helps Dog Bite Victim.
Local High School Dropouts Cut in Half.
“Instead of imagining that our main task is to instruct a computer
what to do, let us concentrate rather on explaining to human
beings what we want a computer to do.”
– Donald Knuth
4
Why Java?
Java features.
!
Widely used.
!
Widely available.
!
Embraces full set of modern abstractions.
!
Variety of automatic checks for mistakes in programs.
Java economy.
!
Mars rover.
!
Cell phones.
!
Bluray Disc.
!
Web servers.
!
Medical devices.
!
Supercomputing.
!
…
James Gosling
http://java.net/jag
$100 billion,
5 million developers
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document5
Why Java?
Java features.
!
Widely used.
!
Widely available.
!
Embraces full set of modern abstractions.
!
Variety of automatic checks for mistakes in programs.
Caveat.
“There are only two kinds of programming languages: those people
always [gripe] about and those nobody uses.”
– Bjarne Stroustrup
6
Why Java?
Java features.
!
Widely used.
!
Widely available.
!
Embraces full set of modern abstractions.
!
Variety of automatic checks for mistakes in programs.
Caveat.
No perfect language.
Our approach.
!
Minimal subset of Java.
!
Develop general programming skills that are applicable to:
C, C++, C#, Perl, Python, Ruby, Matlab, Fortran, Fortress, …
7
A Rich Subset of the Java Language
Primitive Numeric Types
!=
==
>=
<=
<
>

/
+
%

++
*
Integer.parseInt()
Double.parseDouble()
Parsing
Math.max()
Math.min()
Math.pow()
Math.sqrt()
Math.PI
Math.abs()
Math.log()
Math.sin()
Math Library
Math.exp()
Math.cos()
System.out.println()
System.out.print()
System.out.printf()
System
for
if
Flow Control
while
else
!

true
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '08
 DOUGLASW.CLARK

Click to edit the document details