I know and use both Ruby/Rails and Groovy/Grails and wanted to debunk a myth here:
"Interest in Grails/Groovy is diminishing" - I won't comment on trends but there is still a large, active user base and community
I won't list the benefits of Ruby/Rails over Groovy/Grails because I will assume the audience here is familiar with Ruby/Rails.
Specifically here are some benefits of Groovy over Ruby:
- Very good JVM tooling and integration
- Familiar (Java)
- Developer friendly (Ruby has a number of syntax warts, e.g. elvis operator, null safe operator - just to start) syntax
- Optional static compilation
- Optional typing
and Grails over Rails:
- Performance - take a look at techempower benchmarks http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=query
- Spring integration - having Spring built in is often useful in an enterprise context where existing Spring use exists
- Typing is nice if you like that (Mentioned above)
When I need to decide between using Grails and Rails, it usually comes down to developer convenience vs performance. I am asking myself do I want to give up a lot of performance (with Grails) for a little more developer conveniences (with Rails)? Sometimes the answer is yes, sometimes no.
As someone who has done a lot in both frameworks, I have found Grails to be more mature from an enterprise standpoint, and the tooling support is outstanding. IMHO, it's a lot easier to track down what is happening where in Grails as opposed to Rails.
I've also used both languages a fair bit, but I've never used Grails (although I've played with it).
Couple things to add to the pros/cons:
> Developer friendly (Ruby has a number of syntax warts, e.g. elvis operator, null safe operator - just to start) syntax
I would love to see the elvis operator and the null safe operator in Ruby, but I'd also like to see blocks in Groovy.
An addition to the pros of Groovy:
Interacts extremely well with existing Java code. While you can call into Java from JRuby, it's no where near as clean to interoperate with Java in the same code base. In the past I've loved Groovy because I could use it very cleanly inside a codebase that had a lot of Java, e.g. use Groovy to write controllers or data munging code but use Java for most other things.
Sorry to turn this into a framework war, but as someone who made the move from Groovy/Grails to Scala/Play Framework, I can't imagine ever going back. Or in other words, my answer to "A or B?" is "C".
Agreed. Groovy is in my opinion absolutely the nicest and friendliest language to read or write. Scala has some really cool features that I would love to see in other languages, but it also has a tendency to become somewhat unreadable and is a lot harder to get into when you're new to it.
Really? I've been using it but I feel pretty lonely. I ended up creating my own Groovy based version of R / pandas data frames because there is simply nothing out there. I'm curious in what ways you're seeing it used.
I haven't used Groovy much, so I may be completely missing something here, but how is the elvis operator different from a simple guard in Ruby?
Based on the docs for elvis, it looks like
potentiallyFalsyValue ?: safeDefault
is exactly equivalent to
potentially_falsy_value || safe_default
in Ruby
Further, the null-safe operator seems to be the same as #try in Rails and overuse of either is probably a bit of a smell that you might be violating Tell Don't Ask
Yes, I see || as a wart or crufty. Think about the type signature of || in ruby:
<Type 1 or Type2> ||(Type1 arg1, Type2 arg2)
but in how many other languages is this?
boolean ||(arg1, arg2)
C, Java, Objective-C, C++, C#, PHP vs Ruby, Perl, Javascript
If || is used more frequently as a logical operator returning true(1) or false(0) to test logical or (not to be used for assignment), why overload this operator?
Having a separate operator like ?: better shows the intention of the usage. It also resembles the ternary function which has similar functionality.
It's subtle, but I think the difference is that in ruby when potentially_falsy_value is false you will get the safeDefault. But with ?: you would get the potentiallyFalsyValue as false. The only time you get safeDefault is when potentiallyFalsyValue is nil/null
"Interest in Grails/Groovy is diminishing" - I won't comment on trends but there is still a large, active user base and community
I won't list the benefits of Ruby/Rails over Groovy/Grails because I will assume the audience here is familiar with Ruby/Rails.
Specifically here are some benefits of Groovy over Ruby:
and Grails over Rails: When I need to decide between using Grails and Rails, it usually comes down to developer convenience vs performance. I am asking myself do I want to give up a lot of performance (with Grails) for a little more developer conveniences (with Rails)? Sometimes the answer is yes, sometimes no.