Comment

Comment by AtlasBarfed

Oops, sorry those are features java "stole" from groovy.

Java has the nullsafe operator now and the elvis too, doesn't it?

I don't use the spaceship operator much, implicit sorting works pretty well.

Groovy's closures have a lot less GOTCHAs. They simply work as expected, at least to me. Half the time I use java closures and I get complaints in compilation that I don't get in Groovy, but maybe they've improved closures more.

Groovy's GPars library is the bomb for concurrency/parallelism. I don't know if I could function in normal java constructs.

The .with keyword is a sneaky useful technique where you can declare a piece of data like:

"some cli command" .with { it.execute} .with { /* parse output */ }

It allows chained calls that flow naturally. Groovy generally allows pretty compact flowed calls which makes scripts a lot easier.

Groovy scripting with implicit vars is a lot easier than any java scripting, even with the "simplification" described.

The shorthand access/navigation of nested lists and maps, and the map / list literals (also taken by java at some point I think) are really nice to have. Also a + operator for lists and maps I use a lot

Groovy's ability to generically call methods without mucking through 10 lines of reflection is sometimes nice.

The auto-gen of getter/setters is a must have, I think Kotlin has those too?

CompileStatic lets me selectively use full java speed without groovy overhead.

In general, I like Groovy because it is typing-optional. Python and Javascript suck because they don't really have optional type enforcement. Java sometimes asks for too much typing. Groovy lets me select as needed.

The actual sane = for string assignment and == for sane string comparison is nice.

But honestly, Java with the listed features is a lot better. I'll probably still use groovy for doing what would normally done with bash (UGH) since I have a big CLI/scripting library base that handles argument parsing, json, encode/decode, encrypt/decrypt, zip/unzip, in nice compact syntax.

Groovy is basically a dead language now anyway. The world is overrun by JavaScript and Python, and AI looms to replace us all with horrid AI python or javascript glue code.

parent AtlasBarfed 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton