Download - introduction nano programming
CSE1002 Lecture NotesIntroduction
Ryan Stansifer
Department of Computer SciencesFlorida Institute of Technology
Melbourne, Florida USA 32901
http://www.cs.fit.edu/˜ryan/
20 July 2009
Overview of Course
I Introduction. What is CS? What is a computer?
I Review of Java. Data, control constructs, static methods
I Classes
I Generics
I Introduction to Data Structures
Goal: Programming
I Primary goal: programmingI intellectual dreams are translated to realityI rules are simple, yet programming well is difficult, do not
underestimate the challengeI problem solving is hard and difficult to teach
I Secondary goal: introduction to computer scienceI a little at the beginningI and from time to time: BNF, O(N), FSM, invariants
Why Java?
I Why any particular language?
I concrete before abstractI language mastery
I Why not C++?In some ways C++ resembles assembly language, and some thatwould learn C++ first would never realize what high-levellanguages offer.
I Why Java?Good tools, good textbooks, used by AP.
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
Overview of Introduction
I What is CS? Architecture, OS, networking, . . .
I ComputerI ArchitectureI CPUI memory hierarchy
I Interface layers: hardware, operating system, applicationI The Java platform
I JVM and a million other piecesI Java documentationI Java history
I Programming languages — not just Javalearning to program is not just learning about Java
I Program development; debuggers
I Program style; a program is a text file
I I/O, streams
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
What is Computer Science?
computer science. The study of information andalgorithms for virtual and real automata.
I automaton: “self moving” – in our context, self “deciding”mechanism
I information: knowledge represented in a form suitable fortransmission, manipulation, etc.
I algorithm: an unambiguous, finite description in simple steps ofactions
Computer Science is not the study of computers, nor is it the practiceof their use.
I Bosnian: algritem
I Catalon: algorisme
I Chinese (Mandarin):
I Croatian: algritam
I Dutch: algoritme
I Finnish: algoritmi
I French: algorithme
I German: Algorithmus
I Japanese: (arugorizumu)
I Korean:
I Latin: algorithmus
I Spanish: algoritmo
I Swedish: algoritm
I Turkish: algoritma
Mathematics, science, or engineering?
Mathematics. The science of numbers, interrelations,and abstractions.
Science. Systematic knowledge or practice. Acquiringknowledge through the scientific method of naturalphenomena (natural sciences) or human or social behavior(social sciences).
Engineering. The applied science of acquiring andapplying knowledge to design, or construct works forpractical purposes.
What is CS?
I Engineering? Application of science?
I Natural science? Observable phenomena?
I Mathematics? Invisible abstractions?
I Social science? Functioning of human society?
CS is exciting and difficult as it is all these things.
What Does A Computer Scientist Do?
Just like mathematics, everyone in modern society uses computerscience. So getting a computer science degree prepares you foreverything and nothing.
The most visible activity is commanding computers to do our bidding,i.e., programming.
What do you want to do?
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
Fields
I Computer architecture
I Operating systems
I Programming languages and compilers
I Algorithms, data structures, complexity
I Computability theory
I Numerical analysis
I Networking and distributed computing
I Parallel computing
I Database systems
I Software development (aka Software Engineering)
I Human-computer communication/interaction
I Intelligent Systems (aka Artificial Intelligence)
Architecture
Basic five-stage pipeline in a RISC machine: instruction fetch,instruction decode, execute, memory access, register write back.
Operating Systems — paging
Programming Languages and Compilers
Algorithms and Data Structures — Sorting
Theory of Computation — halting problem
Numerical Analysis
A report from the United States General AccountingOffice begins “On February 25, 1991, a Patriot missiledefense system operating ad Dhahran, Saudi Arabia, duringOperation Desert Storm failed to track and intercept anincoming Scud. This Scud subsequently hit an Armybarracks, killing 28 Americans.” The report finds the failureto track the Scud missile was caused by a precision problemin 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
Distributed Computing — barbershop problem
Parallel Computing
single data SISD MISDmultiple data SIMD MIMD
Flynn’s taxonomy
Database Systems
The join of two relational tables
Software Engineering — waterfall model
Human-Computer Communication/Interaction
Intelligent Systems
C3PO and R2D2 are fantasy robots from the movie Star Wars, whileKiva’s industrial robots can efficiently and intelligently move shelves ina warehouse.
End of the overview of different fields of study in computer science
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
Computing is complex. There are many layer of interesting stuffbetween the person and the automaton.
The vastness and minuteness of time and space is a challenge tocomprehend.
SI prefixes1018 exa E quintillion 1 000 000 000 000 000 000
1015 peta P quadrillion 1 000 000 000 000 000
1012 tera T trillion 1 000 000 000 000
109 giga G billion 1 000 000 000
106 mega M million 1 000 000
103 kilo k thousand 1 000102 hecto h hundred 100101 deca da ten 10100 (none) one 110−1 deci d tenth 0.110−2 centi c hundredth 0.110−3 milli m thousandth 0.0110−6 micro µ millionth 0.000 001
10−9 nano n billionth 0.000 000 001
10−12 pico p trillionth 0.000 000 000 001
10−15 femto f quadrillionth 0.000 000 000 000 001
10−18 atto a quintillionth 0.000 000 000 000 000 001
Because computers represent information in binary form, it isimportant to know how many pieces of information can be representedin n bits. 2n pieces of information can be stored in n bits, and so it isnecessary to be familiar with powers of two.
Powers of Two
0 1 00:00:01 second1 2 00:00:022 4 00:00:043 8 00:00:084 16 00:00:165 32 00:00:326 64 00:01:04 about a minute7 128 00:02:088 256 00:04:169 512 00:08:32
10 1,024 00:17:0411 2,048 00:34:0812 4,096 01:08:16 about an hour
Powers of Two
Notice that 210 ≈ 103, so these powers have significance:
10 kilo 1 024 17 minutes20 mega 1 048 576 two weeks30 giga 1 073 741 824 34 years40 tera 1 099 511 627 776 37 millenia50 peta 125 899 906 842 62460 exa 1 152 921 504 606 846 976 age of universe70 zetta 1 180 591 620 717 411 303 424
Powers of Two
Some other powers of have special significance in computing.
7 128 size of ASCII8 256 size of Latin-1
16 65 536 size of Java short31 2 147 483 648 no. of neg int32 4 294 967 296 size of Java int63 9 223 372 036 854 775 808 no. of neg long64 18 446 744 073 709 551 616 size of Java long
Interface Layers
Computing is complex. There are many layers of interesting stuffbetween the person and the automaton.
1. person (user)
2. user-interface (mouse, etc)
3. application (program)
4. high-level language
5. machine language
6. operating system (OS)
7. hardware
8. devices
9. physics
Definitions
I interface – An interface defines the communication boundarybetween two entities, such as a piece of software, a hardwaredevice, or a user. It generally refers to an abstraction that anentity provides of itself to the outside.
I API — An application programming interface (API) is a set ofprocedures that an operating system, library or service providesto support requests made by computer programs.
I IDE — In computing, an integrated development environment(IDE) is a software application that provides facilities to computerprogrammers for software development. An IDE normallyconsists of a source code editor, a compiler and/or interpreter,build automation tools, and usually a debugger.
Simple View of Programming
computer
program
files
OS
monitor
mouse
keyboard
The program controls the computer, yet it needs critical assistance(from the operating system) to communicate with the outsideenvironment and even to run effectively.
For a deeper appreciation of programming a computer we shouldexamine briefly the many layers upon which the user depends.
An important lesson in organizing these complex systems is that theboundaries should be well chosen. Rapidly changing technology,competing business interests, and new insights make it impossible tosettle these boundaries once and for all.
Whole classes like computer architecture, operating systems, compilerconstruction, and programming languages go into the subjects moredeeply.
Hardware and Operating System Platform
Application
System calls: open(), read(), mkdir(), kill()
OS:
File system
NetworkingProcess management
Memory management
Hardware:CPU Memory
Network interface
Monitor Disk Keyboard
Example Platforms
I Hardware: IBM PowerPC, Intel x86, Sun UltraSPARC II
I OS: Microsoft Windows XP, Mac OS X v10.5 “Leopard”, Linux,Solaris 10
Try:
cs> uname -ioRackMac3,1 Darwin
olin> uname -ioX86_64 GNU/Linux
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
Computer Hardware
Computer Hardware–CPU
AMD 64X2 dual core
Computer Hardware–CPU
Computer Hardware–CPU
control unit is the part of the cpu that controls all the internal actions ofthe cpu escially the fetch/execute cyle.arithmetic/logic unit (ALU) is the part of the cpu that does operations:addition, multiplication, etc.memory data register (MDR) is the reigister of the cpu that conaintsthe data to be stored in the computer’s main storage, or the data aftera fetch from the storage. It acts like a buffer keeping the contents ofstorage ready for immediate use by the cpu.
Computer Architecture
Computer Architecture
type access size costregisters 5ns 1e2
caches (SRAM) 10ns 1e6 100.00 $/MBmain memory (DRAM) 100ns 1e9 1.00 $/MB
hard disk 5000ns 1e11 .05 $/MB
As the technology improves and the costs go down over time, thetypical size of each layer goes up. The ratio in access time betweentwo layers influences the design of the computer hardware. When theratio changes significantly a different design may achieve betterperformance.
Computer Architecture
A final note about computers. The computing platform today is lessconcerned about the individual computer and more concerned aboutthe network of interconnected computers on the Internet.
The computer is the network
Slogan of Sun Microsystems
Outline
IntroductionWhat is CS?Brief overview of fields in computer science
Architecture
Layers of Software and HardwareAnatomy of a ComputerThe Java Platform
Java DocumentationHistory of Java
Programming Language Interface
The programming language interface establishes a virtual machine—avritual computer the programmer pretends to use in place of an actualcomputer.Generally a programming language hides little of the underlyingmachine forcing the programmer to interact directly with the operatingsystems in an ad hoc, mixed approach to controlling a computer.Java tried (with mixed success) to build an all-encompassing platform.
Sun Java Platform
enterprise computing
telephony
programs
distributed programs
WWW applications
network centricapplications
Sun Java SE 6 platform overview from the documentation
Sun Java Platform
I Java virtual machine (JVM) specification
I Java programing language specification
I virtual machine implementation (for Solaris, Windows, and Linux),translation tools (java and javac), and development tools
I A core library (the package java.lang), extensive libraries(APIs) for networking, graphics, etc., and additional APIs forspecial purposes (e.g., telephony)
In addition,
I API documentation
I An IDE for developing Java programs, Netbeans
The virtual machine and language have developed over time.Currently we are concerned primarily with what Sun calls the “Javaplatform, Standard Edition Development Kit 6” or JDK 6 for short.
Interface Layers
I java.util, java.awt
I java.lang
I JVM, JRE
I Hardware and operating system platform
See detailed diagram at: http://java.sun.com/javase/6/docs/
History of Java
I Sun Microsystems
I James Gosling
I 1995: WWW, browsers, Java, applets