Language Features


Java's portability is largely achieved through the Java Virtual Machine concept. Instead of compiling a program to a machine-specific code, a Java program is compiled into a machine-independent bytecode. The bytecode, in turn, is interpreted by a machine-specific Java Virtual Machine (JVM). A JVM is small, so it can easily be incorporated into Web browsers. JVMs are available in many other environments: a standalone JVM can be downloaded from Sun's Web site; JVMs can be included in personal digital assistants (PDAs), or incorporated into relational database engines such as Oracle, or integrated development environments (IDEs) such as Borland's JBuilder. This approach means that Java program execution will be slower than a C program, for example. Java, however, is significantly faster than other interpreted languages such as Smalltalk. There can be further performance improvements with the use of just-in-time (JIT) compilers that compile the bytecode into machine-specific code on demand.


Portability is also achieved by having a machine-independent size for all primitive data types such as integer and floating point numbers. This contrasts with C, where maximum sizes are machine dependent.

This has led to Sun describing Java as ''write once, run everywhere." However, this claim is compromised to an extent. For example, the latest versions of most Web browsers support only Java version 1.1. Java version 1.2 applets, which may include features such as Swing, cannot be executed by most browsers. You can get around this by installing a Java 1.2 plugin to run with the browser, but this does qualify the "write once, run everywhere" claim.

Java is an object-oriented language. Object-oriented programming encourages good software engineering practices such as information hiding and code reuse. Object technology has a long history. The first fully object-oriented language, Smalltalk, was developed in 1972 although object features were present in the Simula language before then. The most widely used object-oriented language prior to Java was C++. This was developed in 1985 by adding object features to the then widely used C language

In contrast to C and C++, explicit memory allocation and deallocation is not required in Java. The Java runtime system uses automatic garbage collection to reclaim memory of objects no longer in use. There is no explicit use of pointers in Java programs. Pointers can corrupt areas of memory, producing side effects and consequently making debugging a difficult process. Pointers can even cause the underlying operating system to crash. However, Java shares much of the syntax for data types and control structures with C.

Java differs from pure object languages such as Smalltalk in that primitive data types are not treated as objects in Java for efficiency purposes. Java does provide object wrapper classes for primitive data types for situations where their use is required. Java, through the bytecode compilation process, is faster than the purely interpreted Smalltalk language.

Java is a multithreaded language. Threads are concurrent executions of code under control of a single parent program. Threads can be explicitly created by application programs. Multithreading leads to improved performance and scalability. Java is also a dynamic language: classes are loaded only as they are needed.

Java provides a rich set of classes, or application programming interfaces (APIs). Some of these classes such as input/output or the windowing classes of the Abstract Windows Toolkit (AWT) are part of the language, and therefore are included with Java language releases. Other APIs, such as the Swing graphical user interface, Java Database Connectivity (JDBC), and servlets are considered separate from the language, and so can be released independently if required.

No comments:

Post a Comment