The cleverness of the title of JavaOne 2011 presentation "The Not Java That's Not Scala: Alternatives for Java EE Development" (25182) captured my attention and it was futile to resist the urge to see what the presenter (Justin Lee of Oracle) with that title would talk about in 60 minutes. With that in mind, I returned to the Parc 55 Embarcadero, a conference room in which I've already seen a couple of sessions in this year and several in last year. The session appears to be relatively well-attended though thankfully it is far from standing-room only.
Justin Lee is a GlassFish and Grizzly team member and works with websockets. He is a Basement Coder and has been using Java since 1996. He said that he has used several other languages such as Python, but he has not gotten the chance to use many languages other than Java because Oracle is committed to Java. He also stated that he likes Scala, but wants to avoid the community getting into a mono language focus on Java or even only Java and Scala.
Lee's slide "Why Not Java?" listed some of the frequently stated objections to Java such as "15+ years old," "verbosity," "it's not cool!," and "it doesn't have my favorite feature!" Lee said that there are some things Java will never do and used the example of functional programming. He pointed out that even with lambdas, "Java will never be a functional language."
The slide "Why Not Scala?" listed some commonly cited reasons for not using Scala. He quoted James Gosling, "Academics are driving the bus." He also cited inaccessibility of advanced features to "Average Joes" and "esoteric features." His last bullet of the slide is "rampant feature abuse." I thought Lee made a good point about this last bullet. He pointed out that although it's true that developers can choose to only use the more understandable portions of the Scala language, the problem is that they may be left trying to read and maintain code with some of the more difficult portions that fellow developers put in place.
Lee's "So What's Missing?" slide listed closures, syntax cleanups, succinctness, generics, and concurrency. Although Java has some of most of these, it can stand some improvement in most of them. A second slide with the same title listed functional programming, mutability, null handling, extendability, and modularity. ?Of course, JDK 8 with Project Lambda and Project Jigsaw will address some of these.
Lee said "suggest" may be too strong of a word for his recommendation of the languages Fantom and Gosu because these languages have their "own baggage." Although the abstract says Mirah would be covered, Lee opted not to cover it in the presentation because that language's creator (Charles Nutter) is giving a focused presentation on that language at this conference.Fantom
Lee showed some Fantom syntax. He explained that Fantom does not have arrays, but the List syntax makes them appear to be arrays for ease of use. Literal maps, lists, URIs, types, and "slots" were presented. Lee had slides comparing a Java version of a Person class to a Fantom version of the Person class. This example showed that all constructors in Fantom are named "make" and the "new" keyword precedes the "make" declaration. An ampersand precedes an identifier to represent it as an attribute rather than a method. This example also showed that Fantom methods support default method parameters.
Another slide showed "inheritance and mixins" syntax in Fantom. This slide showed that "initial assignments" use a (Pascal-style) colon preceding the equals sign (
:=) while reassignments use simply the equals sign without the preceding colon.
Fantom stores nullability within the language's format. It never stores null in a "normal" variable, but placing a question mark (?) after a variable name means that it "might store null." Fantom also builds immutability into the language itself. I have long missed Java not having a true
const keyword that actually does something and Fantom does add that. Lee's slide showed using
const on a class declaration and on local variable declarations. I definitely am feeling a bit of "const envy."
Fantom concurrency uses actors similarly to how Scala and Erlang approach concurrency.
Fantom provides standard libraries and Lee showed using these libraries to easily retrieve a web page's content over HTTP, using date literals (which looks surprisingly simple especially when compared to Java's awful Date/Calendar mess), and calculating an HTTP Basic authentication string.
Lee discussed Fantom's approach to modularity and meta-programming. He described Fantom Pods as something like JARs but with additional metadata.
Fantom supports DSL development and allows embedding of other languages within Fantom code. This approach is somewhat similar to using CDATA in XML and makes it easier to plug in other languages and regular expressions without cluttering readability with special escape characters. Fantom can use Java libraries as documented in Using a Java Library from Fantom.
Fantom's Draft is a "mini web framework" that is a "bit like Node.js."
Gosu (Reference Guide) has familiar syntax, closures (Blocks), and generics. Gosu also provides Groovy-like object equality with
== and instance equality with
=== and Groovy-like null safety operator (
?.). In keeping with Gosu's Groovy-likeness, Lee talked about Gosu having properties so that get/set methods do not need to be explicitly called.
Gosu constructors are all named "construct" just as Fantom's constructors are all named "make." Lee also showed that Gosu variable declaration has the variable name first and then the type inferred. Also like Fantom (and C++ and many other languages, but not Java), Gosu supports default method parameters.
Lee included a slide on Gosu's use of delegate. This is a convenient way to "wrap" or "delegate to" an existing class. Lee also showed a slide with less verbose code needed (than Java) to manipulate Strings and Files. I again could not help but think of Groovy's GDK String and File extensions.
Gosu creators state that Gosu's Donkey Patching is something like Ruby's Monkey Patching. Because these are statically invoked extensions, they cannot be used with inheritance or other areas where static methods are not supported.
Lee stated that the part of Gosu he likes best is its XML marshalling and handling. This was impressive in its simplicity, but I again could not help but think that Groovy does pretty well with XML as well.
Gosu includes Ronin, which Lee describes as a JSP-like web built-in web framework. He stated that Gosu has been around for a while and probably uses that JSP-style syntax because of the timing of its creation.