An Unpleasant Introduction
When I was in college (back in 2007), "learning Java" meant "forging Java applets in the dark heart of Mount Eclipse." As you would imagine, this involved a lot of
import java.awt.* and
public class SelfLoathing extends Applet and lava and blood and Uruk-hai. (Some of this is certainly my own failing; my boss, who knows much more about Java than I do, loves Eclipse.) I don't think anyone died as a direct result of writing old-school Java or attempting to use Eclipse, but I witnessed at least one grown man reduced to tears. I finished the semester and swore I would never write Java again.
The Language (Java 8, or "The Ocho")
Java has come a long way in seven years. A more comprehensive guide to those changes is available in this excellent series of posts over on the Parallel Universe blog; for the points most salient to Rubyists, Pythonistas, JavaScriveners, PHPeons, and others of more dynamically-typed persuasions, I've made a short list of the delightful bits of modern Java we're using here at Rent the Runway (TL;DR at the bottom).
To reverse each string in a list in Java 7 and earlier, you used to have to pull a stunt like this (assuming you weren't in an interview and were allowed to use Java's built-in
To a Rubyist, this is something of a cross between waiting in line at the DMV and burning a hecatomb: quite a bit of rigmarole to obtain a simple result (a driver's license, a favorable wind toward Ithaka). Now, you could write truly Javatastic Ruby:
However, you'd be much more likely to write:
Or, if you're feeling fancy:
To quote Eddie Izzard: et voilà. Truly, Ruby is an elegant language for a more civilized age. Could Java ever look like this? Surprisingly, the answer is yes! In Java 8—a.k.a. The Ocho™—you can now write:
Is this as wond'rous as the one-line Ruby version in mine eyes? No. But it's leaps and bounds above the imperative/procedural style to which Java, the quintessential object-oriented language of the 20th (and now 21st) century, has been shackled for the better part of two decades. And this is really only scratching the surface of what's available in The Ocho™ (I'm gonna make this a thing, I swear): better type inference, method parameter reflection, and fibers (sort of) are just a few of the additions that are turning Java into modern Java (and making modern Java a really pleasant language to write).
The Ecosystem (Frameworks and Tooling)
I've found that even more important than the features of the language you write is the ecosystem in which it lives; one of the reasons I quit Haskell was because its package manager, Cabal, was dreadful. (It probably still is, though I haven't checked recently.) Java's package management systems are well-known and mature (I'm a fan of Maven myself), but the same can't be said for the myriad Java web frameworks out there.
First, I'm going to straight up skip J2EE: partly because I'm not old enough to remember it, but mostly because anyone who is probably doesn't want to.
Some people will tell you about "modern" web frameworks like Spring Web MVC or Play. Spring is (near as I can tell) not much more than a wrapper around all the things nobody likes about Java EE, and I haven't been able to discern any core philosophy with regard to best practices or patterns for solving common web service problems. And if this were the worst of these frameworks—if the design were confusing but the underlying technology sound—that would be one thing. I've actually witnessed Play, via some JNI-based Unforgivable Curse, segfault when you added a route. Which is, I suppose, what you get for wanting to do something insane like that.
Enter Dropwizard, which is not only sane, but absolutely delightful. Despite my limited Java superpowers, I got the "Hello, world!" service up and running in about fifteen minutes. Everything worked as expected. It made sense. Though it's a young project (started in 2011 and recently released version 0.7), there's excellent documentation and a helpful (though still somewhat small) community. I'm really pleased it's our framework of choice at Rent the Runway, and I've actually started going out of my way to read Java pull requests to learn more about it and how we use it.
Finally, I'd be remiss in my short survey of modern Java without a brief discussion of IDEs. As mentioned, I despise Eclipse and wouldn't mind seeing it blotted out of all human memory, but I strongly believe in knowing (and, ideally, liking) your tools, so I think anyone productive with Eclipse should continue to use it. That said, I picked IntelliJ when I came back to Java earlier this year, and it's excellent: on-the-fly warnings (which I generate liberally), code completion, automatic refactoring, and (best of all) immediate and smooth integration with Java 8. IntelliJ's certainly not a new tool, but its newest version (13) is, in my humble opinion, the editor of choice for modern Java.
- Dropwizard is a first-class web service framework and the first Java web framework I'm really excited to dig into;
- IntelliJ makes developing in Java (particularly Java 8) a breeze, and I wholeheartedly recommend it. (This is from a guy who spends 90% of his day in Vim.)
Am I going to switch to only writing Java tomorrow? Of course not. But with Java 8, Dropwizard, and IntelliJ, I'm interested in learning more about the language, its platform, and its tools, and I'm excited to build something great with them.