Introduction
To Java - MFC 158 G
Week
2 Lecture notes - Fall 2000
- Evolution of Operating systems
- Early
computers performed one task at a time - 1950's
- Task
requests run in batch - took hours sometimes - punched cards
- Early
Operating Systems were developed to speed up time between jobs - help
operators
- Allowed
smooth transition between jobs - faster throughput
- Timesharing
allowed terminal access to multiusers - each user getting a slice of time
- 1960's (paper terminals)
- Takes
advantage of idle users
- Gives
illusion of dedicated resourses - appear to be running simultaneous
- Personal, Distributed and
Client/Server computing
- 1977
Apple computers were the first 'popular' home computer
- 1981 IBM
PC was introduced - first 'business' computer
- Started
out using floppies between machines - later connected with Local Area
Networks
- LANs
eventually led to distributed computing - work done on several systems
- File
servers - client computers (workstations) led to the concept of
'Client-server'
- UNIX,
Linux, OS/2 MacOS and Windows (95/98/NT) have Client/Server capabilities
- Computer Languages - 3 types
(generation languages)
- Machine language - First
Generation (late 40s - early 50s)
- Directly understandable by the system
(natural language of 'a' computer)
- Consist of strings (reduced to 1's and
0's) for instructing the computer
- Programmer entered 0s/1s directly into
memory - error prone/hard to modify code
- Machine dependant - not portable to
other computers!
- Assembly languages - Second
Generation (early 50s - present)
- English like abbreviations to
represent basic operations of the computer
- Easier to understand than ML
- Allows faster development than ML
- Translator programs called
'assemblers' converted code into ML for runtime
- Not portable to various hardware -
each computer has its own assembly language
- Many instructions required for simple
tasks
- Still used for programs needing
optimized performance (speed/memory)
- High Level languages - Third
Generation (middle 50s - present)
- Single statements could now do substantial
work
- Higher level of abstraction from
source code to actual task
- More 'English like' than lower level
languages - COBOL
- Translator programs called compilers
convert high level code into ML
- C/C++ are commonly used in
client/server environments
- Java is becoming the popular choice
for Internet-based applications
·
Machine code:
§
+1300042774
§
+1400593419
§
+1200274027 (adds overtime pay to base pay and stores in
gross pay)
·
Assembly code:
- LOAD
BASEPAY
- ADD
OVERPAY
- STORE
GROSSPAY (adds overtime pay to base pay and stores in gross pay)
·
High level
language code:
- grossPay
= basePay + overTimePay
- Fourth Generation Languages
- Code generator software development
tools
- Design
a screen for accessing data - code is generated
- Microsoft Access
- Ideal language - generates COBOL-like
code
- History of C++
- Evolved
from C, which evolved from B
- B was
used to create early versions of UNIX (1970)- typeless (no int/string
concept)
- C now
included data types (1972) - used for developing various Operating
systems
- C can be
Hardware independent - if written portably
- C++
developed in 1980s
- Contained some features to extend C
- Capabilities of OOP
- Usage of objects - reusable software
components
- History of Java (James Gosling -
Oak)
- Originally
researched/created for use with 'intelligent' consumer devices (1991)
- Development
in devices was slow - no use for it yet
- WWW
popularity was growing (1993)
- Sun
initially saw potential to use Java for dynamic web content
- Sun
announced Java at a conference (1995) - much interest generated
- Utilized
C/C++ syntax, yet eliminated features that caused programming errors
- Java usage's today
- Used to
create pages with dynamic/interactive content
- Develop
large-scale enterprise applications
- Enhance
functionality of WWW Servers
- Applications
for consumer devices (cell phones, pagers, etc.)
- The Java Environment and phases of
development
- Windows / Solaris OS
- Windows àWindows
- Solaris à
Solaris
- Windows à
Solaris (Xterm emulator - like exceed)
- Phases for execution
- Edit source code
- Compile source code
- Load the compiled bytecode
- Bytecode verification (prior to execution)
- Execution of code
- Edit
source code
- Observe
case sensitivity (in source and external filenames)
- Save
source with the .java extension
- Compile
source code
- translates
source code into java bytecode
- the
language understood by the Java interpreter in execution phase
- use
the javac comand
- creates
a file with source name and .class extension
- Loading
the Bytecode
- Program
gets placed in memory by the class loader
- Applets
are loaded from a remote computer to the browser
- Applications
are loaded using the Java interpreter (using the java command)
- Browsers
supporting java have built in java interpreters
- Bytecode verification (prior to
execution)
- Checks
to assure that the bytecodes are valid
- Checks
that the bytecodes don't violate Java security
- Writing
to hard disk
- Certain
system changes
- Execution
of code
- 'interprets'
the program one bytecode at a time
- performs
the actions specified by the program
- Distinction between compiler and
interpreter
- Compiler creates 'machine independent'
bytecode output (.class)
- Java interpreter (machine dependant)
interprets the bytecode to interact with it's particular hardware
- JIT (Just in Time) Compiler
- Compiles the code as the interpreter
runs
- Produces compiled code and executes
the program in machine language
- more efficient, though not as
efficient as a full compiler
- Full compilers currently under
development
--------------------------------------------------------------------------------------------------
Webopedia’s rather
concise definition of Java:
http://webopedia.internet.com/TERM/J/Java.html
--------------------------------------------------------------------------------------------------
Comparison of High
level vs. Low level program source code:
Sample of a 'hello'
program, written in C, assembly and in machine code (represented as octal using
the UNIX utility {od -b}
-rw-r--r-- 1
fineberg 75 Sep 7 16:32 hello.c
-rw-r--r-- 1
fineberg 1008 Sep 7 16:33 hello.s
-rwxr-xr-x 1
fineberg 678756 Sep 7 16:32 hello.exe
----Third generation language - C++----
#include <iostream.h>
int main()
{
cout << "hello";
return 0;
}
----------------------------------------
-----Second generation language - Assembly language----
.file "hello.c"
gcc2_compiled.:
.global
_Q_qtod
.global
__throw
.section ".rodata"
.align 8
.LLC0:
.asciz "hello"
.section ".text"
.align 4
.global main
.type main,#function
.proc 04
main:
.LLFB1:
!#PROLOGUE# 0
save
%sp,-112,%sp
.LLCFI0:
!#PROLOGUE# 1
sethi
%hi(cout),%o1
or
%o1,%lo(cout),%o0
sethi
%hi(.LLC0),%o2
or
%o2,%lo(.LLC0),%o1
call
__ls__7ostreamPCc,0
nop
mov 0,%i0
b .LL281
nop
mov 0,%i0
b .LL281
nop
.LL281:
ret
restore
.LLFE1:
.LLfe1:
.size main,.LLfe1-main
.section ".eh_frame",#alloc,#write
__FRAME_BEGIN__:
.uaword .LLECIE1-.LLSCIE1
.LLSCIE1:
.uaword 0x0
.byte 0x1
.byte 0x0
.byte 0x1
.byte 0x7c
.byte 0x65
.byte 0xc
.byte 0xe
.byte 0x0
.byte 0x9
.byte 0x65
.byte 0xf
.align 4
.LLECIE1:
.uaword .LLEFDE1-.LLSFDE1
.LLSFDE1:
.uaword .LLSFDE1-__FRAME_BEGIN__
.uaword .LLFB1
.uaword .LLFE1-.LLFB1
.byte 0x4
.uaword .LLCFI0-.LLFB1
.byte 0xd
.byte 0x1e
.byte 0x2d
.byte 0x9
.byte 0x65
.byte 0x1f
.align 4
.LLEFDE1:
.ident "GCC: (GNU) 2.8.1"
-----------------------------------------
-----First generation language - Machine code language---
Portion of (c program) Hello executable
using od -b Interpret bytes in octal
0000000 177 105 114 106 001 002 001 000 000 000 000 000
000 000 000 000
0000020 000 002 000 002 000 000 000 001 000 001 234 144
000 000 000 064
0000040 000 012 122 124 000 000 000 000 000 064 000 040
000 005 000 050
0000060 000 072 000 067 000 000 000 006 000 000 000 064
000 001 000 064
0000100 000 000 000 000 000 000 000 240 000 000 000 240
000 000 000 005
0000120 000 000 000 000 000 000 000 003 000 000 000 324
000 000 000 000
0000140 000 000 000 000 000 000 000 021 000 000 000 000
000 000 000 004
0000160 000 000 000 000 000 000 000 001 000 000 000 000
000 001 000 000
...
0002040 000 000 000 000 000 000 000 000 000 000 000 000
000 000 000 000
0002060 000 000 000 000 000 000 000 202 000 000 000 000
000 000 001 234
0002100 000 000 000 000 000 000 002 057 000 000 001 076
000 000 000 000
0002120 000 000 000 000 000 000 000 000 000 000 000 000
000 000 001 005
0002140 000 000 000 174 000 000 000 231 000 000 002 152
000 000 001 210
---end of sample----