5 ms·
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 t
by bjfish 12y ago
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.
- mbell 12y agoI'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.
- sytse 12y agoIsn't the elvis operator || in ruby? see http://stackoverflow.com/a/7816041/613240 http://stackoverflow.com/a/7816041/613240
- bjfish 12y agoYes, but I think that syntax is a little ugly, see https://news.ycombinator.com/item?id=8916893 https://news.ycombinator.com/item?id=8916893
- _pmf_ 12y ago> but I'd also like to see blocks in Groovy Groovy allows passing a closure to a method with signature (where p3 is a callable) a(p1, p2, p3) as a(some_val, some_val){ closure content } Are Ruby's blocks more powerful?
- thoman23 12y agoSorry 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".
- derpshmerp 12y agoMy experience with Scala Play was very different. Scala is an interminably difficult language fraught with pitfalls. It's much easier to write unreadable Scala code than Groovy.
- mcv 12y agoAgreed. 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.
- johnkpush 12y agoGroovy is gaining popularity among scientists and researchers because of it's ease of use and performance.
- zmmmmm 12y agoReally? 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.
- prophetjohn 12y agoI 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
- nimblegorilla 12y agoIt'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
- prophetjohn 12y agoThe docs seem to state otherwise One instance of where this is handy is for returning a 'sensible default' value if an expression resolves to false or null http://groovy.codehaus.org/Operators#Operators-ElvisOperator http://groovy.codehaus.org/Operators#Operators-ElvisOperator(?:)
- bjfish 12y agoYes, 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.
- rufugee 12y agoAs 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.
- Arnor 12y ago> IMHO, it's a lot easier to track down what is happening where in Grails as opposed to Rails. Do you have any examples here? I can't think of a time when I've had to hunt long to figure out where things are happening in Rails.