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
21 comments
[ 3.3 ms ] story [ 48.1 ms ] threadI'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.
Some tests are faster and some are slower. Nowhere near as efficient as Java.
The boot time is atrocious, but you can run your Rails app multi-threaded in a single process, and once the JIT warms up, it's pretty danged speedy.
For the record, I'm trying to find if there is one dominant framework in Java that everybody's using as there is in Ruby, not necessarily looking for an easy way out ;)
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.
First, there is trusty JSP and EL. They're blazingly fast. But they aren't a framework, there just libraries.
If you want full-stack Rails, but Java, Play isn't bad. I've used it once, but I felt constrained (much like I do in Rails). I probably needed to give it more time because it does do a lot of things.
The newest version of Tapestry isn't bad. They've had the same lead developer on this project for years, so they've really refined this project over time. You might take a look at the programming model and see what you think, it's can be a little different.
I personally like PrimeFaces/JSF2.0. It's good for large applications since the framework handles all the javascript and Ajax in a very elegant way. If There is also a rabid fanbase (check Twitter). There is tooling involved here, so expect a learning curve.
There's others I haven't used, but my IRL friends have told me they like:
GWT - Building single page, javascript applications ThymeLeaf - The sucessor for JSP that uses Spring Framework ZK JSP - A bunch of cool prebuilt widgets for JSP pages
There are many others, but I've only read about them. With Java, you have tons of choice. There is no "one single killer framework" for Java, so take a look around, and find one that suits your style.
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.
Have you found Play to be significantly faster than Rails/worth the context switching?
Basically you have a front-end, written in rails, and a back-end, written in java. The two communicate using REST service calls.
Personally I think for a lot of apps this approac has a lot more cons than pros.
- everyone that wants to work on the app needs to know both ruby/rails and java/whatever else
- multiple ways to handle deployment, continous integration, testing (different tools for java vs ruby).
- have to run multiple apps constantly to be able to do end-to-end testing
- harder to create full-stack integration tests
- deployments between the apps are often coupled and thus require more planning
- more up front API design work for the team. much harder to add new features that require API changes than ones that dont.
- Automated end to end integration testing can be much harder to do with an app made up of multiple services than simply living inside on process and being able to have test code access both databases to seed data.
There are plenty of apps (i'd say the vast majority) where simply does not make sense to cut the codebase in half.
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.