Portability
Java programs are portable across operating systems and hardware environments.
Portability is to your advantage because:
• You need only one version of your software to serve a broad market.
• The Internet, in effect, becomes one giant, dynamic library.
• You are no longer limited by your particular computer platform.
Three features make Java programs portable:
1. The language. The Java language is completely specified; all data-type sizes and
formats are defined as part of the language. By contrast, C/C++ leaves these
"details" up to the compiler implementor, and many C/C++ programs therefore are not portable.
2. The library. The Java class library is available on any machine with a Java
runtime system, because a portable program is of no use if you cannot use the
same class library on every platform. Window-manager function calls in a Mac
application written in C/C++, for example, do not port well to a PC.
3. The byte code. The Java runtime system does not compile your source code
directly into machine language, an inflexible and nonportable representation of
your program. Instead, Java programs are translated into machine-independent
byte code. The byte code is easily interpreted and therefore can be executed on
any platform having a Java runtime system. (The latest versions of the Netscape
Navigator browser, for example, can run applets on virtually any platform).
Security
The Java language is secure in that it is very difficult to write incorrect code or
viruses that can corrupt/steal your data, or harm hardware such as hard disks.
There are two main lines of defense:
• Interpreter level:
• No pointer arithmetic
• Garbage collection
• Array bounds checking
• No illegal data conversions
• Browser level (applies to applets only):
• No local file I/O
• Sockets back to host only
• No calls to native methods
Robustness
The Java language is robust. It has several features designed to avoid crashes
during program execution, including:
• No pointer arithmetic
• Garbage collection--no bad addresses
• Array and string bounds checking
• No jumping to bad method addresses
• Interfaces and exceptions
No comments:
Post a Comment