Java Reference
In-Depth Information
The name of a Java type is of paramount importance. Java does not permit
structural types in the way some other languages do.
All Java variables have types that are known at compile time.
Java code is object-oriented, and all code must live inside methods, which must
live inside classes. However, Java's primitive types prevent adoption of the
“everything is an object” worldview.
Slightly functional
Java provides support for some of the more common functional idioms, but
more as a convenience to programmers than anything else.
Modestly type-inferred
Java is optimized for readability (even by novice progammers) and prefers to
be explicit, even at the cost of repetition of information.
Strongly backward compatible
Java is primarily a business-focused language, and backward compatibility and
protection of existing codebases is a very high priority.
Type erased
Java permits parameterized types, but this information is not available at
Java's type system has evolved (albeit slowly and cautiously) over the years—and
with the addition of lambda expressions, is now on a par with the type systems of
other mainstream programming languages. Lambdas, along with default methods,
represent the greatest transformation since the advent of Java 5, and the introduc‐
tion of generics, annotations, and related innovations.
Default methods represent a major shift in Java's approach to object-oriented pro‐
gramming—perhaps the biggest since the language's inception. From Java 8 onward,
interfaces can contain implementation code. This fundamentally changes Java's
nature—previously a single-inherited language, Java is now multiply inherited (but
only for behavior—there is still no multiple inheritance of state).
Despite all of these innovations, Java's type system is not (and is not intended to be)
equipped with the power of the type systems of languages such as Scala or Haskell.
Instead, Java's type system is strongly biased in favor of simplicity, readability, and a
simple learning curve for newcomers.
Java has also benefited enormously from the approaches to types developed in other
languages over the last 10 years. Scala's example of a statically typed language that
nevertheless achieves much of the feel of a dynamically typed language by the use of
type inference has been a good source of ideas for features to add to Java, even
though the languages have quite different design philosophies.
Search WWH ::

Custom Search