

Ask HN: Rails vs. Java? - christiangenco

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.<p>Is there an equivalent "Rails" for the Java community?<p>1. http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java_2
======
karterk
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.

~~~
ciniglio
For this approach, how do you tie the two pieces together (e.g. the Java and
Rails parts)? Do you have recommendations for where to start learning about
building one system with multiple languages?

~~~
scottschulthess
I believe OP is referring to a service-based architecture.

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.

------
exabrial
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.

~~~
christiangenco
An excellent defense of the Java language Mr. exabrial, but any
recommendations for Java web frameworks? :D

~~~
exabrial
...that's a bit harder to answer. It really depends on YOU, your ability to
learn, and your project requirements :)

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.

------
bartonfink
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.

~~~
christiangenco
Got it. I'll take a look - thanks!

------
lmm
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.

~~~
christiangenco
Hah, fair enough. I'll add Wicket to the list!

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 ;)

~~~
lmm
It's not about looking for an easy way out, you really have to be prepared to
embrace not just new tools but a whole new way of thinking. As a former python
diehard it took me a long, long time to understand why anyone would choose to
use java - but it does have its advantages, and wicket is the best
demonstration I've found of what it makes possible.

------
cheald
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.

~~~
christiangenco
Oh wow, Rails runs in JRuby. Interesting...

~~~
cheald
Yup. The prime caveat is that any gems that use C extensions have to be
replaced with Java equivalents (mysql2, for example), but it runs just dandy.

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.

------
karianna
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.

------
aquaphile
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.

------
dotborg2
Apache Cocoon, MVC framework designed for RAD

