Jump to content

Criticism of Java

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 217.209.140.211 (talk) at 17:14, 23 December 2011. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A number of criticisms have been leveled at Java programming language for various design choices in the language and platform. Such criticisms include the implementation of generics, the handling of unsigned numbers, the implementation of floating-point arithmetic, and a history of security vulnerabilities. Additionally, Java, especially its early versions, has been criticized for its performance compared to other programming languages. Developers have adapted Sun's phrase of "write once, run everywhere" to "write once, debug everywhere" in reference to the numerous differences in underlying platform which still must be taken into account when writing complex Java programs.[1]

Language syntax and semantics

Generics

When generics were added to Java 5.0, there was already a large framework of classes (many of which were already deprecated), so generics were chosen to be implemented using erasure to allow for migration compatibility and re-use of these existing classes. This limited the features that could be provided by this addition as compared to other languages.[2][3]

Because generics were implemented using type erasure the actual type of a template parameter is unavailable at runtime. Thus, the following operations are not possible in java:[4]

public class MyClass<E> {
    public static void myMethod(Object item) {
        if (item instanceof E) {  //Compiler error
            ...
        }
        E item2 = new E();   //Compiler error
        E[] iArray = new E[10]; //Compiler error
    }
}

Unsigned integer types

Java lacks native unsigned integer types. Unsigned data is often generated from programs written in C and the lack of these types prevents direct data interchange between C and Java. Unsigned large numbers are also used in a number of numeric processing fields, including cryptography, which can make Java more inconvenient to use for these tasks.[5] Although it is possible to partially circumvent this problem with conversion code and using larger data types, it makes using Java cumbersome for handling unsigned data. While a 32-bit signed integer may be used to hold a 16-bit unsigned value losslessly and a 32-bit unsigned value would require a 64-bit signed integer, a 64-bit unsigned value cannot be stored easily using any integer type because no type larger than 64 bits exists in the Java language. In all cases, the memory consumed is doubled (This is only partially correct, since Java internally uses either 32- or 64-bit storage for shorter primitive types such as byte (8 bits), short (16 bits), boolean (1 bit)), and any logic that depends on the rules of two's complement overflow must typically be rewritten. If abstracted using functions, function calls become necessary for many operations which are native to some other languages. Alternatively, it is possible to use Java's signed integers to emulate unsigned integers of the same size, but this requires detailed knowledge of complex bitwise operations.[6]

Floating point arithmetic

While Java's floating point arithmetic is largely based on IEEE 754 (Standard for Binary Floating-Point Arithmetic), certain features are not supported even when using the strictfp modifier, such as Exception Flags and Directed Roundings — capabilities mandated by IEEE Standard 754. Additionally, the extended precision floating-point types permitted in 754 and present in many processors are not permitted in Java.[7][8][9]

Performance

In the early days of Java (before the HotSpot VM was implemented in Java 1.3 in 2000) there were many criticisms of performance. Java has been demonstrated to run at a speed comparable with optimised native code, and modern JVM implementations are regularly benchmarked as one of the fastest language platforms available -- typically within a factor of 3 relative to C/C++.[10]

Java's performance has improved substantially since the early versions.[11] Performance of JIT compilers relative to native compilers has in some optimized tests been shown to be quite similar.[11][12][13]

Java bytecode can either be interpreted at run time by a virtual machine, or it can be compiled at load time or runtime into native code which runs directly on the computer's hardware. Interpretation is slower than native execution, and compilation at load time or runtime has an initial performance penalty for the compilation. Modern performance JVM implementations all use the compilation approach, so after the initial startup time the performance is equivalent to native code.

Security

Adobe Acrobat and Adobe Flash are among the most targeted software for security exploits. In 2010, targeting of Java security exploits increased significantly, resulting in Java becoming a common target. Often long-known security holes in the Java virtual machine is targeted. This is tied to high numbers of computers with Java installed and the high percentage of computers that have not been updated with Java security updates. [14]

Critics have suggested that updated versions of Java are not used because there is a lack of awareness by many users that Java is installed, there is a lack of awareness of many users of how to update Java, and (on corporate computers) many companies restrict software installation and are slow to deploy updates.[14][15]

See also

Notes

  1. ^ Wong, William (2002-05-27). "Write Once, Debug Everywhere". electronicdesign.com. Retrieved 2008-08-03. So far, the "write-once, run-everywhere" promise of Java hasn't come true. The bulk of a Java application will migrate between most Java implementations, but taking advantage of a VM-specific feature causes porting problems.
  2. ^ "Generics in Java". Object Computing, Inc. Retrieved 2006-12-09.
  3. ^ "What's Wrong With Java: Type Erasure". 2006-12-06. Retrieved 2006-12-09.
  4. ^ "Type Erasure".
  5. ^ "Java libraries should provide support for unsigned integer arithmetic". Bug Database, Sun Developer Network. Oracle. Retrieved 2011-1-18. {{cite web}}: Check date values in: |accessdate= (help)
  6. ^ Owen, Sean R. (2009-11-05). Java and unsigned integers "Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)". Retrieved 2010-10-09. {{cite web}}: Check |url= value (help)
  7. ^ Kahan, W. (1998-03-01). "How Java's Floating-Point Hurts Everyone Everywhere" (PDF). Retrieved 2006-12-09. {{cite web}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  8. ^ "Types, Values, and Variables". Sun Microsystems. Retrieved 2006-12-09.
  9. ^ "Java theory and practice: Where's your point? Tricks and traps with floating point and decimal numbers". IBM. 2003-1-1. Retrieved 2011-11-19. {{cite web}}: Check date values in: |date= (help)
  10. ^ "Computer Language Benchmarks Game: Java vs Gnu C++". Debian.org. Retrieved 2011-11-19.
  11. ^ a b J.P.Lewis and Ulrich Neumann. "Performance of Java versus C++". Graphics and Immersive Technology Lab, University of Southern California.
  12. ^ The Java is Faster than C++ and C++ Sucks Unbiased Benchmark
  13. ^ FreeTTS - A Performance Case Study, Willie Walker, Paul Lamere, Philip Kwok
  14. ^ a b "Researchers Highlight Recent Uptick in Java Security Exploits".
  15. ^ "Have you checked the Java?".