Java Reference
In-Depth Information
mon with C and C++. Language constructs that caused intermediate-level developers prob-
lems, like memory management and pointer arithmetic, were handled automatically or re-
moved from programmer control altogether. The language was small (as hard as that might
be to imagine now), easy to write, and, above all, free. Just download a JDK, access the lib-
rarydocs (making available clean, up-to-date, hyperlinked library documentation was quite
the innovation at the time), and start coding. The leading browser of the day, Netscape,
even had a JVM built right into it. Combined with the whole Write Once, Run Anywhere
mantra, Java carried the day.
A lot of time has passed since then. Java has grown considerably, and decisions made early
in its development now complicate development rather than simplify it. What sorts of de-
cisions were those? Here's a short, though hardly exhaustive, list:
• Java is statically typed.
• All methods in Java must be contained within a class.
• Java forbids operator overloading.
• The default access for attributes and methods is “package private.”
• Java treats primitives differently from classes.
Over time Java also accumulated inconsistencies. For example, arrays have a length
property, strings have a length method, collections have a size method, and node lists
(in XML) have a getLength method. Groovy provides a size method for all of them.
Java also lacks metaprogramming capabilities. [ 1 ] That's not a flaw, but it limits Java's abil-
ity to create domain-specific languages (DSLs).
1 That's for a variety of good reasons, many of which relate to performance. Metaprogramming depends on dynamic
capabilities like reflection, which was very slow when Java was first released. Groovy in 1998 on Java 1.2 would
have been a daunting prospect at best.
There are other issues as well, but this list will give us a good start. Let's look at a few of
these items individually.
1.1.1. Is static typing a bug or a feature?
When Java was created, the thinking in the industry was that static typing—the fact that
you must declare the type of every variable—was a benefit. The combination of static typ-
 
Search WWH ::




Custom Search