DEV Community

Discussion on: 100 Languages Speedrun: Episode 35: Groovy

Collapse
 
duncte123 profile image
Duncan

Groovy is horrible, so glad that I switched to kotlin.
Even java is more fun to write by comparison.

Collapse
 
taw profile image
Tomasz Wegrzanowski

I'm quite interested in some deeper discussion why many people prefer Kotlin to Groovy. I tried to find any posts about it, and couldn't really find any, and in my one day of experimentation, I didn't really find any serious issues with Groovy.

Collapse
 
duncte123 profile image
Duncan • Edited

On a high level groovy does not have any issues correct, the languages is actually quite fun to work with.

Just things like def myInt = 1; will compile to Object myInt = 1;. Another thing is that it does not work well with java in the same project, I really had to hack around that.

Kotlin on the other hand works amazingly well with java. The better typing that kotlin has is also great.

Groovy also has a lot of weird stuff like "ls -hal".execute().text just executing shell commands, this feels very sketchy to me.

demonstration of executing console commands

Fun things that groovy has are no returns (you can probably guess how this becomes confusing if you just have a variable at the end of a function)

def aFunction() { "Hello world" }
Enter fullscreen mode Exit fullscreen mode

although kotlin does it better

fun aFunction() = "Hello world"
Enter fullscreen mode Exit fullscreen mode