jRuby on Rails vs Grails [closed]
Asked Answered
P

6

10

I'm looking to develop a greenfield web application which will reuse a lot of Java components. To me, the obvious options for this are Grails or jRuby on Rails, but I'm having trouble finding objective comparisons of the two. Are there any clear reasons to pick one over the other with respect to:

  1. ease of integration with existing Java components (outside the persistent domain), e.g. JMS, EIP
  2. support for functional testing frameworks
  3. performance on a single machine
  4. scalability

I am not looking for answers relating to the availability of developers or activity of communities.


(I've checked Grails vs. Rails, and it's not relevant to me)

Patsis answered 17/11, 2010 at 12:39 Comment(2)
Adding to the answers above, grails also has a plugin for JMS.Jowers
I think the answer maybe in checking out what Gems or Plugins each has that can help with the integrations.Ineradicable
P
4
  • ease of integration with existing Java components:

it's easier with groovy, cause groovy is basically java. you do not have big context-switches

  • support for functional testing frameworks

ruby has it's own pile of testing frameworks like rspec/shoulda/cucumber/steak and tons more. since i like ruby syntax i would prefer those

  • performance on a single machine

as far as i know, grails is better in multithreading, because rails did not fokus too much on that in the past. they are currently catching up, so it might be tie.

  • scalability

both scale with the jvm environement. if you have a running infrastructure for java, grails is easier to integrate.

Posthaste answered 17/11, 2010 at 14:0 Comment(2)
thanks for the answer. 1. Any feelings on how much easier integration is for Groovy than JRuby? 2. Good to hear about Ruby's options for testing; are these all compatible with JRuby? 3. I understand that JRuby's threading model is significantly different to standard Ruby's (e.g. it actually uses threads); have you taken this into account? 4. Scaling JRuby might be as simple as scaling Rails applications though - just using a Java application server instead of a Ruby one. Any thoughts?Patsis
1. it's not about integration of Groovy vs JRuby, it's about integration of Grails vs JRuby On Rails. Grails is easier, cause it's just another java lib. JROR uses tools like warbler or custom stacks like TorqueBox. 2. It depends. 3. as in 1. it's about the thread support of Rails. Rails 3 has a Request-Lock by default. 4. No, see 3.Posthaste
M
20

Try both, and pick the language and environment that suits you best. It's true that the Grails stack out of the box is more suited towards Java integration, but many components are just a few lines of Ruby code away from integration with Rails. Rails 3 is a great release that doesn't require you to use ActiveRecord, in fact it would be trivial to use Hibernate for your models instead. See also DataMapper, MongoMapper and a whole host of database adapters for SQL and NoSQL databases alike.

Also, JUnit != functional testing. Instead, have a look at Cucumber + Cucumber-Rails + Capybara + Selenium for an integrated browser automation testing experience. Take a look at https://github.com/elabs/front_end_testing for an example application that demonstrates this stack.

I'll suggest that Ruby is better suited as a web integration language, and JRuby hits the sweet spot of making integration with Java easy as well as pleasing while making a wealth of non-Java libraries available to you. Don't think that Groovy automatically wins because it's "closer" to Java. Sometimes you need to step into a refreshingly different environment in order to have a new look at how to solve a problem.

Disclosure: as a member of the JRuby team my bias is evident in my answer.

Maddocks answered 17/11, 2010 at 17:11 Comment(3)
Wow, 15 upvotes (until now)?! For what? - The questioner has specified four criteria that would make an answer a solution. - However, you're only responding to one of those (functional testing). - What about integrating Java enterprise technologies like JMS (that's been a requirement in the question)? Most likely, there's a loooong distance from JRuby to those.Denitrify
thanks for the (understandably biased ;) response. As @Denitrify says though, this doesn't address all the points mentioned. Also, I'm aware that JUnit is not so much for functional testing; perhaps that should be a comment @ammoQ's answer?Patsis
@robbert +1. What about scalability and performance? jtict.com/blog/rails-wicket-grails-play-lift-jsp Also Grails is not only closer to Java in syntax but in easy of integration too. It's Spring-backed architecture is awesome and very easy to use.Toxinantitoxin
M
5

I know Grails very well (right now I'm working on a Grails project), but not JRuby, so take this as a probably biased opinion: looking at the JRuby documentation, it looks that JRubys integration with Java is a bit more cumbersome, since Java is more native in Groovy than it is in Ruby; therefore, in JRuby, you have a lot of java-specific keywords and methods (e.g. java_import, java_send). Put simply, Groovy is a language targeted specifically at the Java world, while JRuby is, well, Ruby put on the JVM.

Grails has JUnit tests built in.

Can't say much about performance and scalability, but given the good integration with Java, one can always write performance-critical parts in Java when Groovy is too slow.

Morven answered 17/11, 2010 at 13:3 Comment(3)
thanks, you've tackled the first point. Do you have much experience of this integration? A comparison of code snippets might be useful. As for JUnit, I think it's geared more towards unit testing than functional testing; please correct me if I'm wrong. If I understand correctly, rewriting code in Java for performance reasons is an option whether using Groovy or JRuby. Again; please correct me if I'm wrong.Patsis
Alison: Groovy integrates seamlessly with Java, a code snipplet of a Groovy method calling a method of a Java object looks just like Groovy calling Groovy or Java calling Java. About functional testing: you are right, but this link helps you: grails.org/Functional+TestingMorven
Rewriting in Java is an option in JRuby also, sure, but the syntax of Groovy (which is relatively close to Java) and the seamless integration might make it a bit easier in GrailsMorven
P
4
  • ease of integration with existing Java components:

it's easier with groovy, cause groovy is basically java. you do not have big context-switches

  • support for functional testing frameworks

ruby has it's own pile of testing frameworks like rspec/shoulda/cucumber/steak and tons more. since i like ruby syntax i would prefer those

  • performance on a single machine

as far as i know, grails is better in multithreading, because rails did not fokus too much on that in the past. they are currently catching up, so it might be tie.

  • scalability

both scale with the jvm environement. if you have a running infrastructure for java, grails is easier to integrate.

Posthaste answered 17/11, 2010 at 14:0 Comment(2)
thanks for the answer. 1. Any feelings on how much easier integration is for Groovy than JRuby? 2. Good to hear about Ruby's options for testing; are these all compatible with JRuby? 3. I understand that JRuby's threading model is significantly different to standard Ruby's (e.g. it actually uses threads); have you taken this into account? 4. Scaling JRuby might be as simple as scaling Rails applications though - just using a Java application server instead of a Ruby one. Any thoughts?Patsis
1. it's not about integration of Groovy vs JRuby, it's about integration of Grails vs JRuby On Rails. Grails is easier, cause it's just another java lib. JROR uses tools like warbler or custom stacks like TorqueBox. 2. It depends. 3. as in 1. it's about the thread support of Rails. Rails 3 has a Request-Lock by default. 4. No, see 3.Posthaste
M
4
  1. As phoet said, Grails has first-class Spring support, so it's typically very easy to integrate Spring libraries - that's what many plugins do, including the JMS plugin.

    Java code can either be provided in JARs or put in to the project's src/java directory. Groovy classes can reference Java classes which can reference Groovy classes. It's pretty seamless.

  2. Grails has support for HtmlUnit, Selenium-rc & WebDriver through various plugins. Geb has a lot of interest at the moment, especially when combined with Spock.

  3. Test them. I don't know if there are any recent comparisons, but performance typically depends heavily on your application. http://grails.org/ and http://beta.grails.org/ are both running on a single machine - and both are Grails applications.

  4. I gather it's pretty easy to cluster Grails via Terracotta. You can also do it with plain Tomcat if you want. There are options for distributed caching - SpringSource has its own (commercial) offering in the form of GemFire.

Hope that helps, and in the interests of full disclosure I'm a member of the Grails team.

Mallett answered 2/12, 2010 at 15:51 Comment(0)
I
3

In the end, you are going to make a decision on personal choice, comfort with the two languages and the availability of resources, but in the end, the fact that Grails is based on Spring led me to the conclusion that it was the right choice for me. I knew that if all else failed I could fall back to utilizing the tried and true Spring Framework

Icarus answered 17/11, 2010 at 13:5 Comment(1)
thanks. I was kinda hoping it would be possible to make an objective decision, but you might be right.Patsis
T
1

For newcomers interested in this question in 2012...

"With the @CompileStatic, the performance of Groovy is about 1-2 times slower than Java, and without Groovy, it's about 3-5 times slower. (...) This means to me that Groovy is ready for applications where performance has to be somewhat comparable to Java."

Performance Test: Groovy 2.0 vs. Java http://java.dzone.com/articles/groovy-20-performance-compared

And besides the autor, I've used Groovy since 2008 with great success, not only for CV, just to make job done in time business need. Performance is ever relative to what you want to do.

About integration, Grails is really "that good". I've never needed to make one step further to integrate it with existing libraries. On the contrary, the Spring-based nature of Grails made the job even easier.

For those who could complain about micro-benchmarks and real use cases, here is a somewhat old (Grails 1.8) but good one with web frameworks (Grails 1.3.7): http://www.jtict.com/blog/rails-wicket-grails-play-lift-jsp/

Hope this helps!

PS.: I would like to see recent benckmarks with JRuby and other really dynamic JVM languages.

Toxinantitoxin answered 2/9, 2012 at 5:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.