2000 Prentice Hall, Inc. All Rights Reserved
2000 Prentice Hall, Inc. All Rights Reserved
Outline 1.1 Introduction 1.2 What Is a Computer? 1.3 Computer Organization 1.4 Evolution of Operating Systems 1.5 Personal, Distributed and Client/Server Computing 1.6 Machine Languages, Assembly Languages and High-Level Languages 1.7 History of C++ 1.8 History of Java 1.9 Java Class Libraries 1.10 Other High-Level Languages 1.11 Structured Programming 1.12 The Internet and the World Wide Web 1.13 Basics of a Typical Java Environment 1.14 General Notes about Java and This Book
Introduction
Java
Powerful, object-oriented language Fun to use for beginners, appropriate for experienced programmers Language of choice for Internet and network communications Free implementation at http://java.sun.com
1.2 Computer
What is a Computer?
Device for performing computations and making logical decisions Process data using sets of instructions called computer programs
Hardware
Devices comprising a computer Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units
Software
Programs that run on a computer
Output unit
Sends information (to screen, to printer, to control other devices)
Memory unit
Rapid access, low capacity, stores input information
1.4
Batch processing
Do only one job or task at a time
Operating systems
Manage transitions between jobs Increased throughput - amount of work computers process
Multiprogramming
Many jobs or tasks sharing computer resources
Timesharing
Run small portion of one users job, move onto next user Programs appear to be running simultaneously
1.5
Personal computing
Popularized by Apple Computer in 1977
IBM followed suit in 1981 with the IBM Personal Computer
Distributed computing
Organization has a Local Area Network (LAN)
Computers linked to it
1.5
Client/Server computing
File servers offer common programs that client computers access C and C++ popular for writing operating systems, networking, and distributed client/server applications Java used for Internet-based applications
Programming in Java can be more productive than C or C++
1.6 Machine Languages, Assembly Languages and High-Level Languages Types of programming languages
1. Machine languages
Strings of numbers giving machine specific instructions Example:
+1300042774 +1400593419 +1200274027
2. Assembly languages
English-like abbreviations representing elementary computer operations (translated via assemblers) Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY
2000 Prentice Hall, Inc. All rights reserved.
1.6 Machine Languages, Assembly Languages and High-Level Languages Types of programming languages
3. High-level languages
Similar to everyday English and use mathematical notations (translated via compilers) Example: grossPay = basePay + overTimePay
10
C++ spruces up C
Provides capabilities for object-oriented programming
Objects - reusable software components that model things in the real world
11
1.8 Java
History of Java
Based on C and C++ Developed in 1991 for intelligent consumer electronic devices
Market did not develop, project in danger of being cancelled
Java formally announced in 1995 Now used to create web pages with interactive content, enhance web servers, applications for consumer devices (pagers, cell phones)...
12
Class libraries
Also known as Java API (Applications Programming Interface) Rich collection of predefined classes, which you can use
13
1.10 Other High-Level Languages A few other high-level languages have achieved broad acceptance
FORTRAN (FORmula TRANslator)
Scientific and engineering applications
Pascal
Intended for academic use
BASIC
Developed in 1965 Simple language to help novices
14
Multitasking
Many activities run in parallel C and C++ allow one activity at a time Java allows multithreading
Activities can occur in parallel
15
1.12 The Internet and the World Wide Web The Internet
Developed 30 years ago, funded by the Department of Defense Originally designed to link universities
Now accessible by hundreds of millions of computers
16
Compile
Translates program into bytecodes, understood by Java interpreter javac command: javac myProgram.java Creates .class file containing bytecodes (myProgram.class)
2000 Prentice Hall, Inc. All rights reserved.
17
1.13 Basics of a Typical Java Environment Java programs have five phases (continued)
Loading
Class loader transfers .class file into memory
Applications - run on user's machine Applets - loaded into Web browser, temporary Classes loaded and executed by interpreter with java command java Welcome HTML documents can refer to Java Applets, loaded into web browsers To load, appletviewer Welcome.html appletviewer minimal browser, can only interpret applets
18
1.13 Basics of a Typical Java Environment Java programs have five phases (continued)
Verify
Bytecode verifier makes sure bytecodes are valid and do not violate security Java must be secure - possible to damage files (viruses)
Execute
Computer interprets program one bytecode at a time Performs actions specified in program
Phase 1
Editor
Disk
Program is created in the editor and stored on disk. Compiler creates bytecodes and stores them on disk.
19
Phase 2
Compiler
Phase 3
Class Loader Class loader puts bytecodes in memory. . . . . . . Primary Memory Bytecode verifier confirms that all bytecodes are valid and do not violate Javas security restrictions.
Disk
Phase 4
Bytecode Verifier
Phase 5
Interpreter
. . . . . . Primary Memory
. . . . . .
Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes.
20
Performance
Interpreted programs run slower than compiled ones Compiling has delayed execution, interpreting executes immediately Can compile Java programs into machine code Runs faster, comparable to C / C++
2000 Prentice Hall, Inc. All rights reserved.
21
1.14 General Notes about Java and This Book Just-in-time compiler
Midway between compiling and interpreting
As interpreter runs, compiles code and executes it Not as efficient as full compilers Being developed for Java