Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop Java webapps in a Ruby on Rails-like way?

We've got an app that needs to run in a Java app server. I've got to develop a webapp to go with it. I've started reading about Ruby on Rails, and I really like the approach: MVC, convention over configuration, tons of stuff taken care of for you.

I may be dreaming the impossible dream, but are there any Java webapp development frameworks out there that work in a similar way?

Straight JSP is miserable, because logic and presentation are mixed. Simple template systems, like Velocity and Freemarker don't do the database stuff. I don't know much about Spring.

Everybody here knows Java, and we don't have time before the next release cycle to learn an entirely new language and library, else I'd plunge into RoR in a serious way.

like image 679
ccleve Avatar asked Nov 12 '10 03:11

ccleve


1 Answers

Not impossible at all. It's already been done.

Here are a few Java-equivalents:

  • Grails http://www.grails.org/
  • SpringRoo. http://www.springsource.org/roo
  • Spring MVC. http://www.springsource.org/

All are products of SpringSource. If you're getting serious about Java web development, I highly recommend you check them out.

Grails was actually inspired by Rails, hence the name, so you'll see many similarities in features and paradigms between the two, including MVC, convention-over-configuration, and code generation. So if you're looking to get right into Rails-like development in Java, I highly recommend Grails. I should note that Grails has more features than Rails, some of which I think Rails should adopt. An example is Grails provides a service layer to handle all business logic. You could easily implement a service layer in Rails, but its convenience we all love, and because Grails includes it, it is more convenient. I've hopped between Rails and Grails once upon a time, both great frameworks.

Keep in mind that you can do Rails development with Java as well, via JRuby, which is not a bad option either. You get all the features of the Ruby language (v. 1.8), along with the ability to integrate and use Java libraries within your Ruby code.

SpringRoo is SpringSource's new code generator framework, so you can use it with the Spring framework to aid in agile/rapid application development.

Grails is actually built on-top of the Spring framework and Groovy. Groovy is Java-derivative which looks more like a scripting language and provides all the meta/dynamic programming goodness that you see in languages such as Ruby and Python. However, Groovy allows you to write Java code as well, so there's no need to learn it, not entirely at least.

like image 82
John Avatar answered Oct 01 '22 19:10

John