Java and CS

35
Java and CS&E: A Marriage Made in Heaven or Hell? Sanjiva Weerawarana Department of Computer Sciences Purdue University CS&E Spring Seminar Series April 16, 1997.

description

 

Transcript of Java and CS

Page 1: 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.

Page 2: Java and CS

Overview

Introduction to the Java Environment Java Language Java and CS&E Examples Conclusion

Page 3: Java and CS

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

Page 4: Java and CS

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

Page 5: Java and CS
Page 6: Java and CS

Java is ..

A programming language A bytecode specification A virtual machine A type of coffee

Page 7: Java and CS

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

Page 8: Java and CS

Java Applications

Like programs in any other language Full access to system services Platform independent by design

Page 9: Java and CS

Java Platform is Everywhere..

Embedded in Web browsers Embedded in all major desktop OSs JavaOS JavaChip family of integrated circuits

Page 10: Java and CS
Page 11: Java and CS

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” ®

Page 12: Java and CS

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

Page 13: Java and CS

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

Page 14: Java and CS

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”

Page 15: Java and CS

The Java Language Environment

Page 16: Java and CS

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, ...

Page 17: Java and CS

Language Syntax

Very similar to C/C++ Easy to learn Fewer concepts

– no pointers arithmetic– no structs, typedefs– no preprocessor– no memory management

Page 18: Java and CS

Example: Hello World

Public class HelloWorld {

public static void main (String args[]) { System.out.println (“Hello, World.”);}

}

Page 19: Java and CS

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

Page 20: Java and CS

Arrays

Supports (only) 1-dimensional arrays.. Syntactic sugar for multidimensional arrays,

but not the performance (arrays of arrays) Array references are bounds checked

Page 21: Java and CS

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, ...

Page 22: Java and CS

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)

Page 23: Java and CS

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

Page 24: Java and CS

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!

Page 25: Java and CS

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

Page 26: Java and CS

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

Page 27: Java and CS
Page 28: Java and CS

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 ...

Page 29: Java and CS

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

Page 30: Java and CS

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

Page 31: Java and CS

The Java Language Environment

Page 32: Java and CS

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!

Page 33: Java and CS
Page 34: Java and CS

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/

Page 35: Java and CS

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