Java Reference
In-Depth Information
Answering Some Criticisms of Java
Java has had a long history in the public eye and, as such, has attracted its fair share
of criticism over the years. Some of this negative press can be attributed to some
technical shortcomings combined with rather overzealous marketing in the first
versions of Java.
Some criticisms have, however, entered technical folklore despite no longer being
very accurate. In this section, we'll look at some common grumbles and the extent
to which they're true for modern versions of the platform.
n
Overly Verbose
The Java core language has sometimes been criticized as overly verbose. Even simple
Java statments such as Object o = new Object(); seem to be repetitious—the type
Object appears on both the left and right side of the assignment. Critics point out
that this is essentially redundant, that other languages do not need this duplication
of type information, and that many support features (e.g., type inference) that
remove it.
The counterpoint to this argument is that Java was designed from the start to be
easy to read (code is read more often than written) and that many programmers,
especially novices, find the extra type information helpful when reading code.
Java is widely used in enterprise environments, which often have separate dev and
ops teams. The extra verbosity can often be a blessing when responding to an out‐
age call, or when needing to maintain and patch code that was written by developers
who have long since moved on.
In recent versions of Java (7 and later), the language designers have attempted to
respond to some of these points, by finding places where the syntax can become less
verbose and by making better use of type information. For example:
// Files helper methods
byte [] contents =
Files . readAllBytes ( Paths . get ( "/home/ben/myFile.bin" ));
// Diamond syntax for repeated type information
List < String > l = new ArrayList <>();
// Lambda expressions simplify Runnables
ExecutorService threadPool = Executors . newScheduledThreadPool ( 2 );
threadPool . submit (() -> { System . out . println ( "On Threadpool" ); });
However, Java's overall philosophy is to make changes to the language only very
slowly and carefully, so the pace of these changes may not satsify detractors
completely.
Search WWH ::




Custom Search