Criticism of Java
This article's introduction section may not adequately summarize its contents. To comply with Wikipedia's lead section guidelines, please consider expanding the lead to provide an accessible overview of the article's key points. (March 2009) |
A number of criticisms have been leveled at Java programming language for various design choices in the language and platform, such as the introduction of generics, the types available for numeric variables, and the look-and-feel of its default toolkits.
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.[1][2]
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:[3]
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
E obj = (E)new Object(); //Unchecked cast warning
}
}
Another limitation is that primitive types cannot be used in generics; the workaround is using classes that wrap around a primitive type (though this may result in reduced performance).
"Unchecked" warnings as a result of cast expressions, and can usually be eliminated by eliminating the offensive casts. Unchecked warnings also occur when the compiler finds a cast whose target type is either a parameterized type or a type parameter. There are situations where a cast to a type parameter or a concrete or bounded wildcard parameterized type cannot be avoided. At runtime, only the type erasure is available, not the exact static type that is visible in the source code. As a result, the runtime part of the cast is performed based on the type erasure, not on the exact static type. The clone method and invocation of methods via reflection are two well-known cases where an "unchecked" warning is unavoidable (without resorting to using the @SuppressWarnings("unchecked") annotation.[4]
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. Although it is possible to circumvent this problem with conversion code and using larger data types, it makes using Java cumbersome for handling unsigned data. If abstracted using functions, function calls become necessary for many operations which are native to some other languages.[5]
Missing Features
Java lacks certain features that are considered by some to improve readability and/or programmer productivity.[citation needed]
Closures
Closures (like functors) have been a hotly debated topic within the Java community.[6][7] The main contenders have been:
- BGGA by Gilad Bracha, Neal Gafter, James Gosling, and Peter von der Ahe
- CICE (Concise Instance Creation Expressions) by Bob Lee, Doug Lea, and Josh Bloch
- FCM (First Class Methods) by Stephen Colebourne and Stefan Schulz
Initially Sun announced that closures would not make it into Java 1.7, after a schedule extension, Principal Engineer Mark Reinhold (who works on Java SE and OpenJDK) announced at the Java community conference Devoxxthat they'd be included after all.[8][9]
The current proposal is the subject of active discussion.
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. Many so-called "Java gotchas" are not problems with Java per se, but problems that are inevitable whenever using floating point arithmetic.[10][11]
Performance
Java's performance has improved substantially since the early versions.[12] Performance of JIT compilers relative to native compilers has in some tests been shown to be quite similar.[12][13][14]
In a paper written in 1999 by Lutz Prechelt, it is outlined that, statistically, programmer efficiency and experience has a bearing many standard deviations greater on run-time and memory usage than language choice. This paper specifically uses Java as a basis for the comparison, due to its then-bad reputation.[15] Sun Microsystems have taken considerable trouble to address these problems, and regularly produce white papers on this topic.[16] A more recent study (2003–4) gives Java a comparable performance to C++.[17] However, the validity of this study is disputed.[18]
Java bytecode can either be interpreted at run time by a virtual machine, or it can be compiled at load time or runtime into machine 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.
See also
Notes
- ↑ "Generics in Java". Object Computing, Inc.. http://www.ociweb.com/jnb/jnbJul2003.html. Retrieved 2006-12-09.
- ↑ "What's Wrong With Java: Type Erasure". 2006-12-06. http://www.safalra.com/programming/java/wrong-type-erasure/. Retrieved 2006-12-09.
- ↑ "Type Erasure". http://java.sun.com/docs/books/tutorial/java/generics/erasure.html.
- ↑ "Java Generics FAQs - Under The Hood Of The Compiler". http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#What%20is%20an%20unchecked%20warning?.
- ↑ Java and unsigned integers
- ↑ http://www.ibm.com/developerworks/java/library/j-jtp04247.html
- ↑ http://www.javaworld.com/javaworld/jw-06-2008/jw-06-closures.html
- ↑ http://blogs.sun.com/mr/entry/closures
- ↑ http://blogs.sun.com/mr/entry/closures_qa
- ↑ Kahan, W.; Joseph D. Darcy (1998-03-01). "How Java's Floating-Point Hurts Everyone Everywhere" (PDF). http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf. Retrieved 2006-12-09.
- ↑ "Types, Values, and Variables". Sun Microsystems. http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3. Retrieved 2006-12-09.
- ↑ 12.0 12.1 J.P.Lewis and Ulrich Neumann. "Performance of Java versus C++". Graphics and Immersive Technology Lab, University of Southern California. http://scribblethink.org/Computer/javaCbenchmark.html.
- ↑ The Java is Faster than C++ and C++ Sucks Unbiased Benchmark
- ↑ FreeTTS - A Performance Case Study, Willie Walker, Paul Lamere, Philip Kwok
- ↑ Prechelt, Lutz (October 1999). "Technical opinion: comparing Java vs. C/C++ efficiency differences to interpersonal differences". Communications of the ACM 42 (10). http://portal.acm.org/citation.cfm?id=317683.
- ↑ "Java SE 6 Performance White Paper". http://java.sun.com/performance/reference/whitepapers/6_performance.html.
- ↑ "Benchmarks". http://scribblethink.org/Computer/javaCbenchmark.html.
- ↑ "Java vs C++". http://www.freewebs.com/godaves/javabench_revisited/.
External links
- Free But Shackled - The Java Trap, an essay by Richard Stallman of the free software movement (dated April 12, 2004)
- Computer Science Education: Where Are the Software Engineers of Tomorrow? (dated January 8, 2008)
- Java Criticism
If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...
- Pages using deprecated source tags
- Pages with syntax highlighting errors
- Pages with broken file links
- Articles needing cleanup from March 2009
- Articles with invalid date parameter in template
- All pages needing cleanup
- Wikipedia introduction cleanup from March 2009
- All articles with unsourced statements
- Articles with unsourced statements from January 2010
- Java programming language
- Criticisms of software and websites