Introduction
Introduction
Introduction
Ryan Stansifer
14 October 2023
• Programming
• exciting to translate ideas into reality
• basics are simple, yet programming well is difficult; do not underestimate the
challenge
• programming is not just learning the constructs (but there are a lot of them)
• delivery high-quality programs on time; be able to express control flow and
design data in Java
• problem solving is hard and difficult to teach
• Computer Science
• Computer Science is not just programming
• It is easy to lose sight of the big picture, so we have a general introduction
• Other (non-programming) topics from time to time: architecture, Monte Carlo
methods, O(N), invariants, and so on
Computer Science is not the study of computers, nor is it the practice of their use.
Sorting animation
A report from the United States General Accounting Office begins “On
February 25, 1991, a Patriot missile defense system operating at Dhahran,
Saudi Arabia, during Operation Desert Storm failed to track and intercept
an incoming Scud. This Scud subsequently hit an Army barracks, killing
28 Americans.” The report finds the failure to track the Scud missile was
caused by a precision problem in the software.
Nicholas J. Higham, Accuracy and Stability of Numerical Algorithms, SIAM, 1996,
ISBN13 9780898713558. Page 505.
http://www.ima.umn.edu/~arnold/disasters/disaster.html
In the sliding window protocol the window size is the amount of data a sender is
allowed to have sent into the network without having yet received an
acknowledgment for it.
In Internet routers, active queue management (AQM) is a technique that consists
in dropping packets before a router’s queue is full.
Historically, queues use a drop-tail discipline: a packet is put onto the queue if the
queue is shorter than its maximum size. Drop-tails queue have a tendency to
penalize bursty flows.
Active queue disciplines drop packets before the queue is full based on probabilities.
Active queue disciplines are able to maintain a shorter queue length than the
drop-tail queue which reduces network latency.
The Miracle Worker scene from Star Trek 4: The Voyage Home on YouTube.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 44 / 1
The solution to vast complexity is layers. Good layers enable high-quality
specialization, bad layers just increase the complexity.
Software development—programming—is often about creating layers, even in small
programming projects.
In Java there is an extremely important construct in the language calls an interface.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 45 / 1
Computing is complex. There are many layers of interesting stuff between the
person and the automaton.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 46 / 1
Powers of Ten
Documentray short film shown for generations in school rooms
Charles and Ray Eames, 1966 and 1977
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 47 / 1
The vastness and minuteness of time and space is a challenge to comprehend.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 48 / 1
One, Two, Three, Many
A study of people in Nicaragua who were born deaf and never learned Spanish or a
formal sign language has concluded that humans need language in order to
understand large numbers. “Up to three, they’re fine," says Elizabet Spaepen, a
researcher at the University of Chicago and an author of the study. “But past
three, they start to fall apart."
http://www.npr.org/2011/02/09/
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 49 / 1
SI Prefixes
peta P quadrillion 1015 1 000 000 000 000 000
tera T trillion 1012 1 000 000 000 000
giga G billion 109 1 000 000 000
mega M million 106 1 000 000
kilo k thousand 103 1 000
hecto h hundred 102 100
deca da ten 101 10
(none) one 100 1
deci d tenth 10−1 0.1
centi c hundredth 10−2 0.01
milli m thousandth 10−3 0.001
micro µ millionth 10−6 0.000 001
nano n billionth 10−9 0.000 000 001
pico p trillionth 10−12 0.000 000 000 001
femto f quadrillionth 10−15 0.000 000 000 000 001
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 51 / 1
SI Prefixes
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 52 / 1
Four new prefixes to the International System of Units were announced by the 27th
General Conference on Weights and Measures in 2022 in Versailles, marking the
first expansion of the metric system since 1991. The new prefixes are ronna (27
zeroes after the first digit) and quetta (30 zeroes) at the top of the measurement
range, and ronto (27 zeroes after the decimal point) and quecto (30 zeroes) at the
bottom.
The change was largely driven by the growing requirements of data science and
digital storage, which is already using prefixes at the top of the existing range
(yottabytes and zettabytes) for expressing huge quantities of digital information.
Naming conventions hold that prefixes indicating larger numbers end ’a’ like
“giga,” while prefixes for smaller numbers end in ’o’ like “nano.”
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 53 / 1
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 54 / 1
A Memory Aid for the SI Prefixes
Planets:
My very excellent mother just served us nachos.
Mary’s “Virgin” explanation made Joseph suspect upstairs neighbor.
Man very early made jars serve useful needs [period].
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 55 / 1
ISO/IEC 80000-13
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 56 / 1
A computer is a remarkable tool and easily works at all scales. Now some early
history of technology and scientific computing...
The MANIAC (Mathematical Analyzer Numerical Integrator And Computer Model
I) was an early computer built at the Los Alamos Scientific Laboratory. It ran from
1952–1958.
• Klára Dán von Neumann - wrote the first programs for MANIAC.
• Dana Scott (1976 Turing Award) - programmed the MANIAC to enumerate all
solutions to a pentomino puzzle by backtracking in 1958.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 57 / 1
By mid-1953, five distinct sets of problems were running on the MANIAC,
characterized by different scale of time: (1) nuclear explosions, over in
microseconds; (2) shock and blast waves, ranging from microseconds to minutes;
(3) meteorology, ranging from minutes to years; (4) biological evolution, ranging
from years to millions of years; and (5) stellar evolution, ranging from millions to
billions of years. All this in 5 kilobytes—enough memory for about one-half second
of audio, at the rate we now compress music into MP3s.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 58 / 1
Powers of Two
Because computers represent information in binary form, it is important to know
how many pieces of information can be represented in n (binary) bits. 2n pieces of
information can be stored in n bits, and so is it necessary to be familiar with
powers of two.
It is obvious that ⌈log2 n⌉ bits are required to represent n things. Some bit patterns
might be unused.
20 1
21 2 bit patterns
22 4 bit patterns
23 8 bit patterns
24 16 bit patterns
25 32 bit patterns
(What does it mean that one thing can be represented with zero bits? There is no
need to represent one thing as there is nothing else which can be confused with it.)
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 59 / 1
In Java, the expression
32 - Integer.numberOfLeadingZeros(n-1)
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 60 / 1
In Java, the expression
31 - Integer.numberOfLeadingZeros(n)+1
31 - Integer.numberOfLeadingZeros(n)
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 61 / 1
Exponential growth of the covid-19 cases
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 62 / 1
Also Pandemic Math by NYT
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 63 / 1
Indeed, the logarithm scale seems essential for human perception.
The Weber-Fechner law: the intensity of our sensation increases as the logarithm
of an increase in energy.
Gustav Theodor Fechner (1801-–1887), Elemente der Psychophysik.
Log scales: Richter magnititude scale for strength of earthquakes, sound level
inDecibel , pH for acidty, stellar magnitude for brightness of stars, power laws
(population of cities, frequency of letters).
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 64 / 1
Powers of Two (Time in Seconds)
Suppose we double 1 second and double the amount of time again. And, we do
this again and again.
0 1 1 second
1 2 2 seconds
2 4 4 seconds
3 8 8 seconds
4 16 16 seconds
5 32 32 seconds
6 64 about a minute
7 128 about 2 minutes
8 256 about 4 minutes
9 512 about 8 minutes
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 65 / 1
Powers of Two
10 1 024 17 minutes
..
.
19 524 288 one week
20 1 048 576 two weeks
..
.
25 33 554 432 a year
..
.
30 1 073 741 824 34 years
40 1 099 511 627 776 37 millennia
50 125 899 906 842 624
60 1 152 921 504 606 846 976 age of universe
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 66 / 1
Powers of Two
SI prefixes are not supposed to be used for powers of 2 (just powers of 10).
Sadly, abuse of SI prefixes in computer technology has led to confusion. Whereas
1GHz usually means 109 instructions per second, 1GB usually means 29 bytes.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 67 / 1
Powers of Two
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 68 / 1
One challenge in computer science is the vast scale of computing devices.
A computer may have a terabyte (1012 bytes) worth of storage. A computer may
execute ten instructions every nanosecond (10−9 seconds).
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 69 / 1
Layers And Interfaces
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 70 / 1
Precarious pyramid
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 71 / 1
Interface Layers
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 72 / 1
Interface Layers
• Hardware
• OS
• Java API
• Development enironment
• User
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 73 / 1
Definitions
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 74 / 1
A good IDE hides many details of program development from the programmer.
This is good for simple users. But knowledgeable people can innovate and change
the world.
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 75 / 1
Computer Science (Introduction) What is CS? (Layers of Software and Hardware) © 14 October 2023 76 / 1
Simple View of Programming
files
keyboard
program monitor
computer
OS
mouse
The program controls the computer, yet it needs critical assistance (from the
operating system) to communicate with the outside environment and even to run
effectively.
Application:
Memory management
File system
OS:
Process management Networking
CPU Memory
Hardware: Network interface
Monitor Keyboard
Disk
Try:
The Java programming language (and other high-level languages) try to form a
high-level platform.
The subject of this course is programming and teaching programming without any
particular programming language does not seem possible.
There are good reasons to learn any programming language. There is no good
reason to be proficient in one programming language over the rest.
There is no best language for learning the others. So a comprise of different
pedagogic, societal, practical, and scientific factors govern the chose of Java.
Computer Science (Introduction) The Java Platform (Why Java?) © 14 October 2023 84 / 1
“Buzz” about Java
Buzz about Java might mean more jobs, more student engagement.
• TIOBE based on search results
• RedMonk based on github/stack overflow
Computer Science (Introduction) The Java Platform (Why Java?) © 14 October 2023 85 / 1
Computer Science (Introduction) The Java Platform (Why Java?) © 14 October 2023 86 / 1
Computer Science (Introduction) The Java Platform (Why Java?) © 14 October 2023 87 / 1
A study found fewer defects in projects using Haskell, Scala, Go, and Java (which
are statically typed, managed-memory languages) than in C, C++, and Python.
Baishakhi Ray et al. (Oct. 2017). “A large-scale study of programming languages
and code quality in GitHub”. In: Communications of the ACM 60.10,
pages 91–100. doi: 10.1145/3126905 . URL .
Computer Science (Introduction) The Java Platform (Why Java?) © 14 October 2023 88 / 1
The Java universe supports many application with specialized and powerful libraries
and tools.
However, our goal is Java language features useful for programming in all domains
and in other programming languages.
programs
WWW applications databases
• jaotc - static compiler that produces native code for compiled Java methods
(removed)
• jaotc - static compiler that produces native code for compiled Java methods
(removed)
• jar - create and manipulates an archive for classes and resources
• jaotc - static compiler that produces native code for compiled Java methods
(removed)
• jar - create and manipulates an archive for classes and resources
• jarsigner - sign and verify Java Archive (JAR) files
• jaotc - static compiler that produces native code for compiled Java methods
(removed)
• jar - create and manipulates an archive for classes and resources
• jarsigner - sign and verify Java Archive (JAR) files
• java - launch a Java application
• jaotc - static compiler that produces native code for compiled Java methods
(removed)
• jar - create and manipulates an archive for classes and resources
• jarsigner - sign and verify Java Archive (JAR) files
• java - launch a Java application
• javac - read Java class definitions and compile them into bytecode code
• javac - read Java class definitions and compile them into bytecode code
• javadoc - generate HTML pages of API documentation from Java source files
• javap - disassemble one or more class files
• jcmd - send diagnostic command requests to a running JVM
• jconsole - start a graphical console to monitor and manage Java applications
• javadoc - generate HTML pages of API documentation from Java source files
• javap - disassemble one or more class files
• jcmd - send diagnostic command requests to a running JVM
• jconsole - start a graphical console to monitor and manage Java applications
• jdb - find and fix bugs in Java platform programs
• jdeprscan - static analysis tool that scans a jar file (or some other
aggregation of class files) for uses of deprecated API elements
• jdeps - launch the Java class dependency analyzer
• jfr - parse and print Flight Recorder files
• jhsdb - a postmortem debugger to analyze the content of a core dump from a
crashed JVM
• jinfo - generate Java configuration information for a specified Java process
• jlink - assemble set of modules and their dependencies into a runtime image
• jmap - print details of a specified process
• jmod - create JMOD files and list the content of existing JMOD files
• jpackage - package a self-contained Java application
• jps - list the instrumented JVMs on the target system
• jmod - create JMOD files and list the content of existing JMOD files
• jpackage - package a self-contained Java application
• jps - list the instrumented JVMs on the target system
• jrunscript - run a command-line script shell that supports interactive and
batch modes
• jshell - interactively evaluate declarations, statements, and expressions in a
read-eval-print loop (REPL)
• jstack - print Java stack traces of Java threads for a specified Java process
• jstat - monitor JVM statistics
• jstatd - monitor the creation and termination of instrumented Java HotSpot
VMs
• keytool - manage a keystore (database) of cryptographic keys, X.509
certificate chains, and trusted certificates
• rmid - start the activation system daemon that enables objects to be
registered and activated in a Java Virtual Machine (JVM)
• rmiregistry - create and start a remote object registry on the specified port
on the current host
• serialver - return the ‘serialVersionUID‘ for one or more classes in a form
suitable for copying into an evolving class
Intel quad
Definition (ALU)
The arithmetic/logic unit (ALU) is the part of the cpu that does operations:
addition, xor, rmultiplication, etc.
Definition (MDR)
The memory data register (MDR) is the register of the cpu that contains the data
to be stored in the computer’s main storage, or the data after a fetch from the
storage. It acts like a buffer keeping the contents of storage ready for immediate
use by the cpu.
A final note about computers. The computing platform today is less concerned
about the individual computer and more concerned about the network of
interconnected computers on the Internet.