Starting Grails

I'm delving into learning Grails, in my continual effort to pick up fringe languages and frameworks while avoiding the popular ones.

Grails is a framework for web development loosely modeled off of the Rails framework for Ruby. Instead of using a scripting language like Ruby however, Grails is built on top of Groovy, a JVM-based compiled language with a lot of syntactic sugar that allows it to behave very similarly to a dynamic scripted language like Ruby or Python. Beyond that, it's also got a lot of the python/post-java stylistic options such as optional semicolon, list comprehension, etc. that developers are growing to love.

So, with that in mind, I fired up my Ubuntu 14.04 dev box, and started fiddling around with Grails. Groovy is a JVM language, so the first step was installing a JVM. I actually pulled down the Sun Java 8 JVM, figuring why start with an old version. Then I started reading around. The first tool that I happened on that seems invaluable is The Groovy enVironment Manager, or GVM for short. It does what rvm does for Ruby, or what pyenv does for python: It allows you to set up your user environment with a version of groovy and grails separate and independent of what your OS packages might install. For Mac users, that's probably not a huge deal if you're using homebrew or macports, since those tend to keep up to date packages, but Ubuntu, RedHat, and others tend to lag a bit behind on development tools. For example, the current version of Groovy is 2.3.0, but Ubuntu 14.04 has Groovy 2.0.0 in it's repos. Further, even if you've got the most recent version in your OS repos, and you're working with anyone else, or on a brown-field project, you almost certainly won't want to be using the newest version. So, GVM allows you to download and install any version of Groovy up through the current version, as well as different releases of Grails, and a couple other key dependencies and add-ons.

So, with GVM solidly in place, I pulled down Groovy 2.3, Grails 2.3.8, and started trying to build a simple hello world app:

$ grails create-app hello
| Created Grails Application at /home/greylurk/hello
$ cd hello
$ grails create-controller hello
< Massive java stack dump >

Well, damn. It turns out that Java 8 is actually not compatible with Groovy/Grails right now. I expect that to be resolved reasonably soon, but for now, Java 8 is a no go.

Ok. So, now after downgrading my java to Java 7, Let's give that another try:

$ grails create-app hello
| Created Grails Application at /home/greylurk/hello
$ cd hello
$ grails create-controller hello
| Compiling 10 source files
| Compiling 141 source files
| Created file grails-app/controllers/hello/HelloController.groovy
| Created file grails-app/views/hello
| Created file test/unit/hello/HelloControllerSpec.groovy
$ grails run-app
| Server running. Browse to http://localhost:8080/hello

And so, a quick browse to http://localhost:8080/hello shows a welcome page! Let's call that a victory for now.