Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Grails but code in Java?

I have heard and read quite a bit on the Grails framework. I understand from their website that it's a framework designed to target the Groovy language.

Grails looks like a framework more suitable for small to medium applications than frameworks like Spring and Struts which need too many configurations to setup. But at the same time I'm quite reluctant to jump right into the Groovy language for reasons such as not mature enough, difficult to find developers, etc.

I want to know whether I can use Java instead of Groovy and yet leverage the benefits of Grails (or something that models after Rails). So, can I use the Grails framework but code in Java language? Even though Groovy seems like a superset of Java and they both can work seamlessly with each other, I can't find a place that says specifically whether or not I can use Grails and write in Java.

like image 215
Carven Avatar asked Feb 23 '14 06:02

Carven


1 Answers

You can, but you'll lose all benefits of Grails. Like dynamic methods, artifacts, controllers, most of plugins, etc. And I don't think that you will be able to use GORM (database mapping) from Java.

What you'll lose:

  • GORM and Domains -> you can use Hibernate instead
  • Controllers and URL Mapping -> Spring MVC
  • Services - > you can use plain old Spring Beans instead, it's basically the same thing
  • most plugins, because most of them are based on some Groovy features, dynamic methods or GORM

So, basically you'll get just standard Spring MVC app with limited GSP views and, maybe, more convenient way to configure app, easier usages of static files/resources and i18n.

PS You could always write Groovy code with Java-like syntax. And use all Grails features at this case (moving slowly to Groovy, you'll see)

PPS There is no shortage of Groovy developers, btw. Every Java developer can develop Groovy. It just takes 2-3 hours to read some introduction to Groovy for Java programmer.

like image 118
Igor Artamonov Avatar answered Nov 15 '22 18:11

Igor Artamonov