Java and CS
-
Upload
sammy17 -
Category
Technology
-
view
816 -
download
4
description
Transcript of Java and CS
Java and CS&E: A Marriage Made in Heaven or Hell?
Sanjiva WeerawaranaDepartment of Computer Sciences
Purdue University
CS&E Spring Seminar SeriesApril 16, 1997.
Overview
Introduction to the Java Environment Java Language Java and CS&E Examples Conclusion
Introduction: The Java Platform
Many platforms in computing: Microsoft Windows, Macintosh, OS/2, UNIX, NetWare, …
The Java platform allows delivering and running interactive, dynamic and secure applets and applications on various computing devices
The Java Platform
Sits on top of existing ones or native Java language is entry ramp Allows programs written in Java to be run
on the Java platform on any hardware/OS combination
“Write Once, Run Anywhere” SM
Java is ..
A programming language A bytecode specification A virtual machine A type of coffee
Java Applets
“Small” programs run within a browser In Web case, when a page is accessed the
programs embedded in that page are automatically downloaded and run
Should be small / modular to prevent long download times
Security is considered: sandbox mode
Java Applications
Like programs in any other language Full access to system services Platform independent by design
Java Platform is Everywhere..
Embedded in Web browsers Embedded in all major desktop OSs JavaOS JavaChip family of integrated circuits
Definition:Network Computing Computing is moving from the desktop to
the network .. A greater and greater %ge of activity is net-centric
May or may not imply use of Network Computers (NCs)
A possible solution to the costly desktop maintenance problem?
“The Network is the Computer” ®
Network Computers
NC Reference Profile by Oracle, Sun, IBM, Netscape and others:– min 640x480 screen; support for JPEG, GIF,
WAV, AU; various Internet protocols, Java, security, …
“Thin client” model Goal is for entire desktop to be software
which is downloaded from central server
Enabling Technologies / Forces:Why now? The Web Low cost, high power machines Low cost network access Economics- charging for information will
not pay the bills Economics- desktops are expensive Microsoft
Java and Network Computing
Java does not introduce new computer science; it combines features of many things .. So why Java?– Java is multiplatform by design– Java is embeddable– Java is secure– Java is reasonably efficient– “being at the right place at the right time”
The Java Language Environment
Java Language
History– Started in 1990 by Jim Gosling– 1991- Consumer Electronics– 1993- Interactive TV– 1995- Internet
Simple, Efficient, Small, Architecture Neutral, Secure, Robust, Multi-Threaded, ...
Language Syntax
Very similar to C/C++ Easy to learn Fewer concepts
– no pointers arithmetic– no structs, typedefs– no preprocessor– no memory management
Example: Hello World
Public class HelloWorld {
public static void main (String args[]) { System.out.println (“Hello, World.”);}
}
Simple Data Types
Usual types are available, but no unsigned numbers
Numerical behavior is well defined on all platforms
If data sizes do not coincide with native, then emulate
Arrays
Supports (only) 1-dimensional arrays.. Syntactic sugar for multidimensional arrays,
but not the performance (arrays of arrays) Array references are bounds checked
Object Oriented
Java is a more object oriented language than C++: everything but the built-in primitive types must be objects (i.e., there are no user defined functions, only classes)
Forces design of software to be really OO, and does not allow the pretend-OO style of C++
Has all the usual OO concepts: inheritance, encapsulation, abstraction, ...
OO in Java
Java has single implementation inheritance– a new class can be defined by extending (I.e.,
using) the code from exactly one pre-defined class
Java has multiple interface inheritance– a new type can be defined by extending (i.e.,
starting with) the definition of any number of previously defined types)
Java is Multithreaded
Allows execution of multiple “threads” of execution within the same address space
Preemptive multi-threading No explicit locks Built-in primitives for synchronization Condition variables
Reality Check: Java is Not Everywhere : Native Code JNI: Java Native Interface - allows
extending the Java runtime using code written in other languages
Shared libraries are dynamically loaded and code executed
Language / security checks are off in native code!
Garbage Collection
Unused memory is automatically located and reused: Garbage collection
Never have to free anything! Conservative mark and sweep algorithm Most GC is done when idle
Security
Compiled code is verified Language constraints are enforced at link Untrusted code in trusted environment:
sandbox approach using security manager Control over class loading Digitally signed classes
Java and CS&E: Roles
User Interfaces– Data/problem input– Monitoring and steering– Data visualization– Definitely valid ...
Metacomputing– Java as a “glue” to build large scope systems– Definitely valid ...
Java for HPC
No question about popularity:– more and more schools are teaching Java as the first
programming language– has >400,000 developers in 2 years– relationship to Web and ability to easily interact
with others is driving its popularity
HPC?– Opportunity to unify languages for core computing
and application building
Java Performance
Clearly performance is key– Note: Web/Net speed is not issue; assume high-
bandwidth networks (vBNS, I-Way, …)
Java is currently compiled into bytecodes and then interpreted– Just-In-Time (JIT) compiler makes difference
Java can be compiled into native code directly
The Java Language Environment
Compiled Java
Is feasible .. Can be high performance Programming model needs to be curtailed
to help compiler:– watch exceptions
Sun claims next version is close to compiled C performance!
Examples of Java in CS&E
LINPACK Benchmark in Javahttp://www.netlib.org/benchmark/linpackjava/
HotGAMShttp://gams.nist.gov/HotGAMS/
MatrixMarkethttp://math.nist.gov/MatrixMarket/
Net //ELLPACK http://pellpack.cs.purdue.edu/netpp/
Virtual Programming Laboratoryhttp://www.npac.syr.edu/
Conclusion
Java is here to stay .. At least for the time being!
High performance and Java and not incompatible
Selective use of native code is still needed and ok ..
Real systems are falling into place