For web developers used to wrestling with Java and XML, Grails is a breath offresh air. Developers are instantly productive, picking up all the benefits of theRuby-based Rails framework without giving up any of the power of Java. Grails in Action is a comprehensive look at Grails for Java developers. It coversthe nuts and bolts of the core Grails components and is jam-packed withtutorials, techniques, and insights from the trenches. The book starts with an overview of Grails and how it can help you get your webdev mojo back. Then it walks readers through a Twitter-style social networkingapp-built in Grails, of course-where they implement high-interest featureslike mashups, AJAX/JSON, animation effects, full text search, rounded corners,and lots of visual goodness. The book also covers using Grails with existing Javatechnology, like Spring, Hibernate, and EJBs. Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.
Not to be too much of a self-apologist, but let me preface this review by indicating that my frustration (and hence my lower rating) comes largely from gaps in my own knowledge. But as a result of those gaps, I wasn't able to reap this book's full benefits. So first, what was my impression:
Grails in Action is a fast-paced overview of the Grails platform, with an even quicker overview of the Java-based Groovy language that powers it, and some at-a-glance discussions of some other underlying frameworks and technologies (e.g., Spring, Hibernate, SiteMesh). The book's approach is to take you through the platform in a learn-by-doing approach, walking you through the major language features by building an application in Grails that takes advantage of all (or at least most of) its major features. By building the application alongside the authors' text, you get yourself familiar with those features, their syntax, and the philosophy behind it all.
Sounds great; but, a brief segue on why I didn't reap the full benefits:
My work is mostly on the front-end, and over the past couple years I've been writing object-oriented JavaScript almost exclusively. But as Grails has been getting introduced into the mix for a lot of new projects, it was time to dive in. And despite my excitement about making the transition into a more full-stack role, my day-to-day would still be mostly on the front-end. When Grails got onto my radar, I knew right away that most of the work I would do was going to be in the controllers, views, and layouts. So that's what I wanted to learn about; I wanted the best possible introduction to Grails for front-end engineers.
So why the disappointment? Grails in Action wasn't really written for front-end developers. I suppose I could have figured this out if I'd taken a look at the pedigrees of either of the authors--there's a lot of Groovy and Java there. But that colors the approach, and when they say "previous experience with Java web development is an advantage"--they mean it. Not knowing Java--and/or not doing much work on the band end--will slow down your understanding.
With that out of the way, what were the good and the bad?
THE GOOD:
(1) I agree that the "learn by doing" approach is the best way to go. Nothing helps it "stick" quite like getting your hands dirty. That said, this particular learn-by-doing was a strange mix of hand-holding (e.g., "Right, OK that was obvious.") followed by cavalier glossings-over of other aspects (e.g., "Wait--what?--where did that come from?").
(2) Part 1 ("Introducing Grails") and Part 2 ("Core Grails") are fantastic overviews of the core "90% of your time" features in the Grails platforms. There are some outstanding and very clear explanations of those features, the philosophies that guided the implementations of those features, and how best to apply them in a given context. By the end of Chapter 6, you'll be in a decent position to start banging away on your own apps.
(3) The chapters on build systems, writing your own Grails scripts, and plugin development are very informative and show the kind of real power that lives under the Grails covers.
THE BAD: And/or, the critiques both big and small, and a few other things that couldn't be helped:
(1) The Grails community is moving fast, and though I would not call the book "out of date", there were some quirky differences between Grails 1.1 (the current version when they wrote it) and 1.3.5 (the version I had installed during my reading). One example that came up during the first chapter: their exercise on pages 19-20 said to type "new Quote" when what was really needed was the namespaced version ("new qotd.Quote").
(2) As I already mentioned, the emphasis on the book is much more about what's going on in the back end and so front-end developers (like myself) may find themselves a bit lost or otherwise not getting what they came for. The authors write "some experience with web development (in particular CSS, HTML, and JavaScript) is assumed"--but I felt like you could get by without really having much more than a cursory knowledge of these. (JavaScript and CSS really didn't come up in any substantive at all.)
(3) There's an awful lot of time given to writing tests and testing. OK, I get it--testing is important and can help you save yourself from yourself. But there were quite a few features of the language that got not-as-much (e.g., "At what point is UrlMappings.groovy parsed? processed? How does that work?") or else not-at-all (e.g., "What's supposed to go in that 'src' directory?") coverage that would have been nice to see instead of that whole chapter on testing.
(4) Plugins, plugins, plugins... Again: "OK, I get it..." As a platform, Grails is all about plugins--it's a conglomeration of plugins to start with, and it has a vibrant community of plugin writers. And that is marvelous. But once plugins are introduced (in (surprise!) the chapter on tests and testing), every chapter after that includes a line that reads "grails install-plugin name-of-plugin". Perhaps that is (shall we say) idiomatic Grails development, and perhaps the implied take-away is "install the plugin and examine its source code", but that time might have been better spent discussing the problem and the "how" of the solution instead of just dropping one in.
TO CONCLUDE:
I would stand by Grails in Action as an excellent primer on the major features of Grails, and its hands-on approach should help you get comfortable with the key features quickly. But if you're a front-end developer looking to get started with Grails, this probably is not the best introduction. It seems to skip over some aspects of the platform or else give only cursory explanations, but then it spends a lot of time talking about and working with domain classes and the technologies behind them. Again, this is probably fine if you're already a seasoned Java or Groovy programmer on the back-end, or already fancy yourself an adept full-stack developer--but if you've spent most of your time in the browser, you may find it tough to wade through some of what's in here.
For my money, I'm still looking for that good introductory book on Grails. Grails in Action was worth the read, but I think I'll need to give it a second pass after I've found my feet.
A comprehensive if not complete list of tutorials and recipes to concur Grails! So yes, Grails has been inspired by Rails, but even without me knowing much Rails it is evident that Grails is a super feature reach, extensible web framework that utilizes verified, well known components as Spring, Hibernate/GORM, Quartz, Active MQ and more which makes it stands out like on the shoulders of a giant. A very flexible, convention over configuration (makes a lot of heavylifting behind the scenes) system. The book itself is another shiny star: the author and publisher did a very good work in releasing a very thorough material. It is written the way I like it - by submerging a reader into deep waters - by jumping right into creating a working web application! Besides, I read not long time ago on another RAD tool - Flask. I was therefore able to look at Grails from the retrospective of a user of another web framework: what stood out is the absence of configs in Grails, or the extensive need to tackle them, and no numerous pip installs as in Flask. The impression I am under after reading this book, Grails is a super productive framework. And indeed, it works well with any databases (RDBMS' and NoSQL, even Graph databases) and seamlessly integrates with Java libraries. The book aims high, too - to make the reader not less than a Grails productive developer. Kudos to Peter and Glen! Who are advocates of Grails/Groovy, and successfully sell the Framework. Yet the authors have a unique talent of explaining things in simple words, e.g. closures, dynamic programming were explained elegantly. More on Grails and what is done well in the book:
Ajax support is dynamically built-in, nice! Grails has a very strong, mature IoC implementation (I am impressed) Operating in the Cloud is well enough covered (a big bonus nowadays) The book covers the text search options using Searchable that may become Elasticsearch; Also covers RESTful services and how to expose API in your app to make it consumable from outside The book makes a quick stop (I advocate there should had been more coverage) on Single Page Apps with Angular.js There is a special emphasis done on protecting your application from malicious use or such common exploitations as SQL Injection; Performance tuning, legacy integration, database transactions, custom build processes, and even how to develop and publish your own plugins
I liked chapter 4 on building a UI, Ch 13 on RESTFUL services, and the Scheduling in Part 15 then 16 on NoSQL the most. If you ask me if I had any bad experience that would be the what I feel an excessive amount of time dedicated to testing code and various techniques to doing so, hey but it is really necessary. Nevertheless, it is a 5 out of 5 mark.
We're using Grails at work. I went through the first chapter and the starting tutorial. I was using Grails 1.1.1, but ran into some snags. The save() method of domain objects didn't work. I downgraded to version 1.1 and it worked fine. I upgraded to version 1.2-M3 (experimental) and it worked, but something failed later on when I introduced a service, as per the example. The section on testing talked about integration tests, but the code samples were for unit tests. The book could have used more proof reading.
Buying the physical book entitled me to download the PDF version for free. That's nice.
It mentioned Guice in passing when talking about dependency injection. I hoped there would be a way to use Guice with Grails. That would have been awesome. But a look at the index and a search through the PDF showed one a single reference to the word "Guice". Too bad. It seems Grails uses Spring internally for its dependency injection needs. It does have an interesting automatic injection mechanism for certain classes. Controllers, for instance, only need to create a variable with a given service's name and it gets injected automagically. It doesn't seem to work for tests, though; I can't ask for a service instance to be injected in my test for the service.
There is a very nice section on testing that shows you how to unit test the various artifacts like domain classes, controllers, services, etc. The examples include mocking. There is also a section on integration tests. I wrote some unit tests and the facilities added to Java's Collections API made creating test data a synch.
There is a long list of plugins for Grails. It would be nice to have a more exhaustive introduction to the major plugins. There is a nice chapter that talks about a few plugins, but it is tied a little too closely to the sample application the authors are building throughout the book. Some would be useful to me, others wouldn't. Other plugins are introduced through other chapters, such as acegi when talking about security. I understand that the list of plugins is ever-changing and that a book cannot really keep up, but I feel like there are gems hidden in there that I am going to miss because of information overload.
Between this book and the online documentation, I have found answers to almost all my questions. I did have to peek at the code on a few occasions.
This update brings it up to Grails 2.3.7. Between final edits and actual publication, Grails is now on version 2.4.2 and some people are already pointing out incompatibilities.
We're still using Grails 1.3.7 at work, so I got to read about all the cool new things in Grails 2 without being able to use any of them. And there is plenty to get excited about! Just about every chapter brought in some new piece that made me wish I could use it in my day-to-day job.
The book itself was much better put together than the first edition. The examples flow better from chapter to chapter and I didn't find any inconsistencies.
The thing that impressed me the most was how they use Spock for all their testing. It makes the tests much more readable and possibly much easier to manage. I remember using RSpec with Ruby, and Spock brings the same expressiveness to Grails. It still supports JUnit-based tests from before, so you don't have to rewrite all your tests when upgrading a project, but you should definitely switch to it for any new tests.
The new where queries are much more flexible than the old findAllBy... dynamic queries. Since they use AST transforms, they are much more flexible and can work beyond strictly SQL-based data stores. They are also much easier to test, not requiring integration tests for anything beyond trivial queries.
The chapter on Platform Core and pub/sub messaging showed me how large chunks of code that I've written are now baked in, for all intents and purposes. I used Spring Events to build an event-based architecture, but the event in Platform Core are much better integrated and require a minimum of code. And moving from there to distributed events (JMS-based or otherwise) is also now trivial to add to any application.
Caching is now as simple as putting a few annotations here and there. Much better than an intrusive service that needs to be wired by hand everywhere it's needed.
The authors did a good job of showing how to include the latest technologies into a Grails application. AngularJS, Redis, MongoDB, and Neo4j all make guest appearances. Everything you need to build a cutting edge app.
Grails In Action is an excellent introduction to Grails. The book starts in Chapter 2 with an example application you might write with Grails (a Twitter clone called Hubbub) and, by the end of that chapter, makes the reader realize he or she just wrote a usable Twitter clone, though one that is admittedly rough around the edges. This illustrates agile principles of iterative development and it helps the reader get somewhat familiar with rails.
The real strength of the book is that every single chapter after 2 continues to expand on this application, illustrating each of the aspects of Grails naturally though this application. The reader never has to re-familiarize oneself with new domains, they can keep building on what they've learned.
This is a great way to learn Grails. The chapters are all appropriate length, and they cover enough material for someone to get started. As a first book on Grails, Grails in Action is ideal.
That being said, Grails in Action makes the mistake of a lot of Rails books, letting the "magic" stuff continue to seem magical. Some of the best Rails books, such as The Rails Way, dive deep into Rails, explaining not only how to use it, but how some of the "magic" is accomplished. As a programmer with a natural curiosity, I find myself often wondering how things work, and Grails in Action didn't do much to answer my questions. There was quite a feeling of "this is just how it works, it's a mystery" which doesn't give me the tools I need to modify or adapt what I'm doing.
I plan on reading Grails: The Definitive Guide next, as I'm hoping it dives deeper into Grails. Grails in Action left with me with "swiss-cheese knowledge" as in, I have a lot of holes and gaps in my understanding. It's a good way to get started, but if I had to do something the book didn't cover, I'd have to Google things, rather than rely on my intrinsic understanding of Grails to make an educated guess on how to accomplish something.
Good first book, but if you know Grails decently it falls short.
Before reading I had some experience with Java, Spring, Hibernate.
Book uses example example application Hubbub (twitter clone) to demonstrate all features and where you can use them in real world. I think this teaching method worked well.
This book covers wide range of topics from basics to using NoSql databases. Most Grails chapters provides great depth.
My only gripe is that after books release few month Grails 3 was launched and some chapters aren't relevant anymore, because new version was total rewrite and some features changed. I see that this can be frustrating to novice developers who picks up this book and tries to use it as reference for Grails 3.
An excellent book for going from knowing nothing about Grails to an intermediate programmer with the framework. Even if you don't read the whole thing, you'll get up to speed on the fundamentals early in the book. I haven't read any of the "in Action" series before, but after this book I'm looking forward to reading more of them.
Given the dearth of available tomes on Grails, I hadn't much choice. As a reference, it's okay. Reading straight through, though, you'll want to make sure you've got a good sized stash of your favorite stimulant handy. I don't know why, but most Manning books are just dryer than grandpa's kisses.
Surprisingly good. This book did a good job explaining grails and even more important making be excited to program in it. I highly recommend this book.