Rails or Grails

Rails or Grails?

One other thing worth mentioning: the design philosophy of both framework is somewhat different when it comes to the model. Grails is more "domain-oriented" while Rails is more "database-oriented".

In Rails, you essentially start by defining your tables (with field names and their specifics). Then ActiveRecord will map them to Ruby classes or models.

In Grails, it's the reverse: you start by defining your models (Groovy classes) and when you hit run, GORM (Grails ActiveRecord equivalent) will create the related database and tables (or update them). Which may also be why you don't have the concept of 'migrations' in Grails (although I think it will come in some future release).

I don't know if one is better than the other. I guess it depends on your context.

This being said, I'm still myself wondering which one to choose. As Tom was saying, if you're dependent on Java you can still go for JRuby - so Java reuse shouldn't be your sole criterion.

Learning Ruby on Rails any good for Grails?

Mmh, I don't know how to say this. Some people might bash me over this.

Language (Groovy and Ruby)

As a language I reckon Ruby is more funky compared to Groovy. Groovy only exists to ease Java programmer as you don't need to learn too much new syntax. But overall I reckon is not as funky as Ruby. Groovy wouldn't be the JVM language that is worth to learn based on attender's vote in this year's JavaOne but instead Scala is the one to go. Besides that, the original creator of Groovy himself does not have faith in the language he created himself in the first place.

Community and Job openings

As for the community, Grails community is not as big as Rails, though since the acquirement by Spring more and more people are using it in serious application. Rails has more job openings in the market compared to Grails (that is if you want to invest in looking a new job).

The framework (Grails and Rails)

But, as a framework, if you really care about maintainability and need access to Java framework and legacy Java system, Grails is the way to go as it provides cleaner access to Java. Grails itself is built upon several popular Java framework (Spring & Hibernate). Rails itself IMHO is funky like Ruby itself, but it's funkyness costs you maintainability. Matz himself prefers Merb over Rails 2 because Rails create a DSL on top of Ruby which is really against the Ruby philosophy. And I reckon because Rails itself is opiniated, which in turn if you don't have the same opinion as the creator, it might not fit your needs.

Conclusion

So in your case, learn Grails as that is the company's consensus (you need to respect the consensus) and if you still want to secure your job. But, invest some time learning Rails and Ruby too if you want to open a chance getting a new job in the future.

Groovy/Grails :: Ruby/Rails :: 2011 State of the framework

Rails and Grails are both excellent frameworks with their current releases. You really can't go wrong with either. Here are some things I find interesting about them though:

Rails

  • Rails (Ruby) does not scale as well as Grails (Groovy). You will need more horsepower to run your application. This isn't a big deal at all with PaaS options like EngineYard (and hopefully a AWS BeanStalk Rails option in the future), but it might just cost a little more to run a Rails app vs a Grails app (obviously JRuby is also an option to though).
  • Rails is slightly better with NoSQL alternatives currently, but Grails is catching up quickly
  • Rails has many more plugins, but this can lead to trouble if you use some that aren't maintained (a lot of them don't currently work with Rails 3 yet either).
  • Rails is more mature and has more features at this point in time because it's been around longer
  • Rails REST support is amazing
  • There are many more "big" Rails websites than Grails
  • Ruby is much more popular than Groovy - TIOBE
  • No dependence on Oracle, ha! (Grails obviously needs the JVM)

Grails

  • Grails integrates with the JVM better than JRuby
  • Grails GORM is better than ActiveRecord (IMHO), although Rails 3 opened the door a little bit for other persistence options, but all the books, tutorials, etc all use ActiveRecord
  • Grails View taglibs are better than <=%...%> in view
  • Grails plugins are well documented and clearly state whether they are supported by SpringSource or not
  • SpringSource is investing heavily in Grails
  • There will be many more corporate jobs for Grails than Rails in the future, but more startups use Rails (where do you want to work?)

My perspective

  • I used Rails a couple years ago, I'm working on a Grails project now
  • I like them both better than Django (Python) or Zend Framework (PHP)
  • I plan to learn Lift (Scala) next

My Recommendation

  • If you have never done Java development and are working on a side project for a small to medium website, go with Rails
  • If you are working at a big company that uses Java, try pitching Grails to your management as the "next Java framework" they should invest in
  • If you are working on "the next twitter or foursquare," well then you are smart enough to answer this question yourself! :)

Ruby on Rails vs Grails vs. Spring ROO vs. Spring App

First you can have a look to these related questions :

Rails or Grails?

Learning Ruby on Rails any good for Grails?

https://stackoverflow.com/questions/1283935/what-technology-asp-php-joomla-rails-grails-for-a-website-from-scratch

Is Grails worth it?

Is Grails (now) worth it?

Now, I will try to answer you according to your requirements you have communicated and the information I have gathered from the internet and my own experience.

Ruby on Rails

I do not advice you to start with RoR because you are a Java developer and you will have to learn a new language (Ruby) and a new environment (Rails). The hosting issue is not a real issue. You can have a VPS hosting plan for $10 (www.enjoyvps.com) perfectly suited for small grails app. If you application needs more memory, you might need to add another 10 Bucks.

If you hosting is really THE critical factor, go with Python/Django or PHP/Kohanna (a very good MVC framework). Otherwise, according to your background, Grails is more suited for you than Rails.

Grails

Few months ago, I had the same dilemma as yours and I decided to have my way with Grails. Why?

Because it's cool !! I mean, community is very helpful and dynamic, Groovy is a pleasure to develop with (be careful : thereafter , there are good chances that you will loath Java). Also, it is a state-of-the-art framework based on very-well established technologies (Hibernate, Spring, Java) and hence, it can improve considerably your market value as a developer. Grails is my favorite

Spring Roo

Roo is Grails for Java. So if you don't want to learn Groovy and if you need pure Java application (that will always run faster than a Groovy-based app), go with it. The community is smaller than Grails but the project is supported by SpringSource who is quite active in the community. I think that if you want to go as fast as possible, this is the solution for you.

Spring Application

You should choose this option only if you don't like Spring Roo integrated technologies (Hibernate, JSP, Maven...) and you want Java absolutely. Otherwise, there is no interest (except for educational purposes) of spending hours of configuration and tuning when you can build sophisticated enterprise applications in a best-practice manner within minutes (with Rails, Roo or Grails).

Each of the options above will provide you enough performance for the application you want to build. A lot depends on best practices for website applications like good architecture design, correct usage of caching strategies and requests optimization...

My Bottom Line

If you have some time to spend for learning new concepts (Groovy, RAD...), go with Grails. If not, go with Roo. Forget about Spring App and Rails.
If hosting is THE issue, so go with Python/Django. You can deploy on GAE, it's free scalable, performant and you will deal with the same concepts as Rails or Grails.

Grails vs. Rails

Previous related questions can be found here:

Rails or Grails?

Learning Ruby on Rails any good for Grails?

https://stackoverflow.com/questions/1283935/what-technology-asp-php-joomla-rails-grails-for-a-website-from-scratch

Is Grails worth it?

Is Grails (now) worth it?

Is developer productivity higher on Ruby on Rails or Grails?

If all you're looking for is a 75% answer: grails

I've done significant development on both platforms, though my major rails experience ended about a year and a half ago (before rails 2.x was released).

I've been heavily involved in grails development since grails 0.5.

The answer really depends quite a bit more on the developers and infrastructure that will be available to work on the project. If you're looking to deploy to a standard java app container (like Tomcat), I think that Grails is the better choice. If you're looking to do something with mongrel/rack/pound/etc. Pick rails.

If there are particular gems/jars that fit your business problem, that would obviously affect your decision.

The choice of Grails for me isn't so much because I think that it's better at solving all kinds of problems, but more because I like the grails developer community better and I like the groovy language a little more.

I've also found grails to be an easier sell to the places I've worked at over ruby/rails. There are many more java shops around here and it's less of a leap for them to make that transition.

This is a personal preference and I could easily see someone else going the other way.

Rails has quite a few things going for it, and I think the test driven development story there is much better (though I'm working on trying to fix that).

Active Record and Hibernate with GORM

Where does Hibernate fit in ? Rails talks to the database without
Hibernate and why does Grails need hibernate?

On a lighter note, this is similar to saying "Grails talks to database without ActiveRecord, so why does Rails need ActiveRecord" :)

ActiveRecord and Hibernate just happen to be the default implementations of database access for the "Model" layers of RoR and Grails respectively.

Actually for Grails, it's more correct to replace "Hibernate" with "GORM" in the above sentence. Like even the OP rightly mentioned, they fulfil the role of an "ORM component" in the two frameworks. The point that GORM is defined at a higher level of abstraction than a typical ORM, is already covered by @Sudhir and @Joshua in their answers. But, of all the possible implementations, Hibernate is the default one; so to assume that "it is the only way" is not unusual.

(As a sidenote, GORM may no longer be the acronym it used to be, where R = Relational, because there are many non-relational implementations today. It's high time now that it becomes a word on its own: "Gorm"; just like "Ajax" is no longer the acronym it used to be :) Or maybe a new acronym GDM for "Grails Data Mapping" – the Github name of the project?)

So the short answer to your last question…

is it possible to use Grails without Hibernate?

…is "yes".

But if you were to ask "is it advisable to use Grails without Hibernate?", the answer would be: "it depends… but NO for practical purposes!"

If you're using a non-relational data store, then it's a no-brainer. You don't have much of an option; each non-relational data store has at max 1 implementation of GORM. In fact, you might even be forced to not using GORM at all (depending on whether an implementation is good enough, or even exists!). Btw, yeah Grails can be used without GORM too! Whether it's worth it, is a decision to be made for the particular project.

But if you're using a relational database and still don't want to use Hibernate, you could use the JPA implementation of the GORM using the gorm-jpa plugin. But it seems to have not progressed beyond a milestone release since 2012. And I have never used it, to be able to comment on whether it works flawlessly (or at least as good as Hibernate).

Or if for any reason you find that the Active Record pattern (RoR's default implementation) suits better for your application than the Data Mapper pattern (this is what Hibernate follows), then you could probably use something like JavaLite or ActiveJPA or even Spring JDBC templates (mentioned by @Vivek, but you'll have to first implement the ActiveRecord pattern with it), and then either use it standalone (outside GORM) or maybe even implement your own GORM implementation of the ActiveRecord pattern using one of them. Who knows, that might make it easier for other Rails developers to pick up Grails :)

tl;dr

In other words, the safest and quickest way to use Grails with a relational database is to go with the Hibernate implementation of GORM.

Note

For migrations, Liquibase is a great tool. There's even a Grails plugin.



Related Topics



Leave a reply



Submit