200 likes | 420 Views
“ Perfect Quote ”. You know you've achieved perfection in design, Not when you have nothing more to add, But when you have nothing more to take away. - Antoine de Saint Exupery . Language Design.
E N D
“Perfect Quote” You know you've achieved perfection in design, Not when you have nothing more to add, But when you have nothing more to take away. - Antoine de Saint Exupery. Java Goals
Language Design • One thing the language designer should not do is to include untried ideas of ones own. The task is one of consolidation, not innovation. - C. A. R. Hoare • In language design, the central problem is to organize a variety of concepts in a way which exhibits uniformity and generality. - J. C. Reynolds Java Goals
Conflicting goals lead to difficult trade-offs. • Safety checks “burden” the compiler and/or the run-time. • Safety and machine independence may exclude efficient low-level operations. • Type systems restrict programming style in exchange for strong guarantees. Java Goals
A language addition should whenever possible solve new problems beyond its original purpose --- not create new problems through its interaction with other mechanisms. A prudent language designer, having toyed with a possible new facility, and encountering incompatibilities with more important properties of the design, quickly retreats. -- Bertrand Meyer Java Goals
Language Specification Programs • (dynamic) Software Machinery • (static) Naming Environments • What entities can be named? • How are the names organized into groups? • How are the names made known where ever they are needed? Conventions are no substitute for enforced constraints. Java Goals
Java : Design Goals A general-purpose concurrent object-oriented language for the Internet. Java Goals
Top Ten Design Goals Java Goals
Simplicity • Programmer Perspective • Automatic garbage collection. • “Unconstrained” array type. • Implementer Perspective • Only “single” class inheritance. • Restricted overloading. • E.g.,Pascal > Modula-2 > Modula-3. Java Goals
Portability • Hardware Independence • Java source => “Architecture Neutral” Byte code • Operating System Independence • Java APIs for I/O, networking, GUI, concurrent programming, etc. Java Goals
Portability • Architecture-neutral. • Size of integer, char, etc and meaning of floating point operations fixed by the language (not by an implementation). • All “behavioral” aspects of a Java program defined by the Java language spec. • Order of evaluation of operands fixed. • Error and Exception handling. Java Goals
Object-Oriented Programming • Programming with abstract data types • Data Abstraction • Separation of Spec. and Impl. • Modularity • Logically related entities are textually close. • Encapsulation • Controlling visibility of names. • Code and Interface Reuse • Inheritance ; Dynamic binding Java Goals
Java • Class-based language. • Has object types (based on classes). • Subclassing implies subtyping • but there is subtyping independent of subclassing. • Static typing Java Goals
Reliability and Robustness • Strong Typing • every variable and every expression has a type known at compile-time. • type limits the values a variable can hold and the values an expression can produce at run-time. • Exceptions • signaling violation of semantic constraints. Java Goals
Java : Compiler and Interpreter source code javac byte code java native code mips pentium sparc alpha Java Goals
Interpretation and Security • Java programs arecompiledintobyte codesfor a (hardware-independent)Java Virtual Machine, and is executed by an interpreter. • Just-In-Time compilerconverts byte codes into native codes, for efficiency. • An interpreter forJVMverifies and thenexecutesJavabyte codes. This step incorporates Security Checks. Java Goals
Evolution of Sun’s JDK • Java 1.0: Interpreter • Java 1.1: Interpreter + JIT Compiler • Java 2 : Hotspot • Profiling and Adaptive Dynamic Compilation of “hot” code • Method in-lining and other aggressive optimizations, and Decompilation • Improved Memory Management for long-running (server) programs • Fast Thread Synchronization Java Goals
Concurrent Programming • Threads can share address space. In Java, threads are modeled after Hoare’s monitors. • Java is a multi-threaded system, which is very convenient for coding interactive or multi-media applications. • Doing I/O concurrently with reading a document. (downloading via browser) • Periodic updating of the screen with data acquired in real-time. (sports/stocks ticker) Java Goals
Distributed Processing • HTML and WWW contributed immensely to the sharing of (distributed) static data. • CGI scripts enabled customization of responses based on user input (client-server). • A Java applet can further react to user input and change behavior dynamically. It can provide an alternative to client-server model in that it runs on the client machine. Java Goals
(cont) • Java supports network programming. • Java supports mobile computing. • Compiled to compact, platform independent byte codes • Dynamic linking. • KVM Java Goals