Ask HN: Rails vs. Java?
My go-to framework for the past 5 years has been Rails, but I keep hearing about how - in terms of scalability and speed - you can't beat "Java" (but never any mention of the framework being used, and there are quite a few[1]). I'd like to see if the syntactical hassel is really worth the speed boost.
Is there an equivalent "Rails" for the Java community?
1. http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java_2
Play is the closest - but it's nowhere near the maturity of Rails. One good strategy that I see a lot of companies adopt is to write a services layer in Java/Scala and then keep the front-end Rails app part light weight. This way, you get the benefits of a robust, type-checked backend and the flexibility of Rails for the strictly web related stuff like asset pipelines etc.
Of course, the downside is that you need to switch context between two languages. However, this has not bothered me in the past too much.
If you want a serious discussion about Java, watch this video from an Engineer at Urban Airship: http://www.infoq.com/presentations/Java-next
The short summary is: Yes, it's worth the syntactical hassel because your tooling takes care of it for you. No, you won't be writing code with Notepad anymore... but would/should you trust a carpenter that insisted nailing every nail in your house with a hammar instead of pneumatic air nailer?
Java is not just a language, it's a tool suite. So Java "sucks" until you learn the tooling. After your learn the tooling, it's fast, simple, productive, and out-scales anything.
Play! is meant to be a Rails-like framework for the JVM. I use it at Mapquest (version 1.2), and I like it so far. It contains its own compiler and server, so you don't need to rebuild or redeploy when you're developing like you might in other frameworks.
I've used Play! 2 for a freelance gig, and didn't like it as much. It tries to compile EVERYTHING (HTML templates, your routes file, etc), and for the simple app I was trying to accomplish, that simply wasn't necessary and led to a lot of unnecessary fighting.
I'd recommend giving Play! a try.
If you try to write rails and ruby in Java you will leave angry and disappointed. I would suggest you look for a Java-oriented framework that leverages Java's strengths (I love wicket for the way it uses java's strong typing to enforce properly reusable components, and make upgrades easy); that way even if you return to ruby you'll have learned something.
Have you tried JRuby? You get all your Ruby on top of the JVM. By a number of anecdotal accounts, it's quite fast once you get past the JIT warm-up period. You also get the ability to use native Java libraries from your Ruby code, which gives you a really nice transition mechanism if you decide to move towards a pure Java solution.
Several people have mentioned Play. There's also Grails, designed as an familiar clone of Rails. There's also Spring Roo, and JBoss's SEAM. Scala also has Lift and Clojure has Compojure (if Lisp style languages are your thing) So plenty of choice!
I'd highly recommend using Matt Raible's JVM web framework evaluation technique and then following up with a prototype in the top two. Time spent up front deciding on the framework that fits you will be time well spent.
For reference, if nothing else, look at the open-source derivatives of WebObjects. Per Wikipedia: "Apache Tapestry has a design and philosophy similar to that of WebObjects. Tapestry is frequently combined with Apache Cayenne, a persistence framework inspired by EOF." The WebObject 5.x series was built around Java.
Apache Cocoon, MVC framework designed for RAD