4 ms·
Grails is decent in my experience but I have two major gripes after working on a large Grails project 1. code reloading (ie change code, see results) doesn't w
by babs474 14y ago
Grails is decent in my experience but I have two major gripes after working on a large Grails project
1. code reloading (ie change code, see results) doesn't work reliably and server restarts are slow
2. The ORM is still based on hibernate.
Is it just me or does anyone else have an incredibly difficult time with hibernate? I've wasted many stressful days debugging weird flush exceptions. I've never had trouble with ActiveRecord. I think it boils down to the concept of a "session" in hibernate, which is essentially a giant global variable begging you to touch it or look at it wrong, whereupon it will plot its revenge by deciding which obscure exception to throw at flush time.
- mbell 14y agoHibernate is useful in one situation: you have a transaction that has to exist across actions taken by multiple disparate services, and you still need the container to manage this for you. In my opinion, if your in that situation, you either have an application that is an edge case, or you've architected your application poorly. My rule of thumb: If it has the word 'enterprise' anywhere in it's name or description. Avoid it like the plague, only use it if its the last available option.
- babs474 14y agoCouldn't agree more about the enterprise sentiment. That is why I like things like Grails, that try and drag the enterprise java world, kicking and screaming into the modern era of ruby on rails style mvc and such. I think Grails mostly succeeds at this modernization, but I have to give fair warning that there are still some enterprisey bits (Spring, which isn't so bad and Hibernate, which will bite you) down in the guts. edit: Forgot to mention that Groovy is a fantastic, under-appreciated language with some neat features that should get more attention. Groovy is a major selling point for using Grails.
- mbell 14y agoI love groovy. Anytime I have something 'Java-JVM' that isn't performance critical, I write it in groovy. But even that mindset is falling away given the ability to use @CompileStatic. The best part of groovy to me is that I can use it where I want, when I want, with a single POM dependency and without (generally) having to think about how it interacts with existing Java code. When I write a Jersey controller, I start in java, if I hit a point where I'm thinking "this would be easier with a closure" or "defining an entire inner class here is stupid", I stop, change the file ending from .java to .groovy, and code away.
- vorg 14y ago> Anytime I have something 'Java-JVM' that isn't performance critical, I write it in groovy. But even that mindset is falling away given the ability to use @CompileStatic. The @CompileStatic-based static compilation in Groovy only began being written 1 year ago (in October 2011), and was only mature enough to be included in a production-ready version of Grails (version 2.2) a few weeks ago (December 2012). Scala has had static compilation from the very beginning, and was rewritten between Scala 1.x and Scala 2.x. Stick to dynamic typing if you're using Groovy, even stuff that isn't performance critical.
- arockwell 14y agoYes, that was my exact experience with Hibernate. I spent two years working on apps that used Hibernate and I never felt like I really understood how it worked. ActiveRecord for the most part "Just Works" for me in comparison.
- eeperson 14y agoI agree that the Hibernate's session can make debugging maddening. You should check out EBean (the default Java ORM bundled with Play 2). It is basically Hibernate without the stateful session stuff. I had never heard of it before Play and now I am really surprised that more people aren't using it.
- tomaslin 14y agoGrails 2 does change the reloading agent to a custom one from SpringSource compared to previous versions - https://github.com/SpringSource/spring-loaded https://github.com/SpringSource/spring-loaded . Hopefully that does take away much of the code reloading woes. Also, you are not restricted to hibernate since the GORM stuff has been refactored and now supports new hotnesses like MongoDB and Redis - https://github.com/SpringSource/grails-data-mapping https://github.com/SpringSource/grails-data-mapping
- bsb 14y agoThere are also now GORM plugins for all the nosql solutions - lots of people use it with Mongo, redis, etc. Also you can switch to JPA and use any JPA provider
- adrianmsmith 14y ago"Is it just me or does anyone else have an incredibly difficult time with hibernate?" I absolutely won't use Hibernate for any new projects. I don't understand why anyone is using Hibernate. Here is a write-up of my experiences with it: http://www.databasesandlife.com/hibernate/ http://www.databasesandlife.com/hibernate/