by zmmmmm · 13y ago · 0 comments
Where Python is usually trying to have just "one way" to do things, Groovy offers you a million. Python actually share's much of Java's annoying desire to keep the default namespace clean and hence make you import modules to do just about anything useful. While Python puts simplicity and cleanliness on a pedestal, Groovy is unashamedly pragmatic, letting you do any dirty thing you feel like or need to do to get your job done.
In complete contradiction to Python's direction of eliminating it (eg: forcing brackets on print() statements) Groovy gives you incredible amounts of optional syntax - add semicolons? if you want ... or not ... except sometimes the syntax gets ambiguous they are required. Use brackets on your function calls? If you want ... or not ... except sometimes the syntax gets ambiguous, so they are required. The author didn't even mention optional static typing which not only enforces type correctness on parts of the code you apply it too, but dramatically speeds them up. So much freedom makes it easy for Groovy code to end up messy and unstructured compared to Python.
I'm currently in a situation where I switch between Groovy and Python coding on alternate days. I definitely prefer different things about each. Groovy definitely seems more powerful when I just need to get a simple job done. It is incredible what you can cram into a single line.
I hope Groovy continues to prosper, but I worry it's getting lost among the hype around more "sexy" languages. I think it's by far the best language for many jobs.
If anything, Python seems to be dominating in large part because of its unabashed lack of sexiness (or what passes for it in modern programming circles: cleverness, and cuteness).
When the syntax get ambiguous, it's up to the developer to know they're required, just like with parentheses around expressions using infix operators of various precedences. The compiler or IDE won't tell you - you just get the incorrect result from running the code.
> The author didn't even mention optional static typing which not only enforces type correctness on parts of the code you apply it too, but dramatically speeds them up.
Groovy's original use case was quick and dirty scripts running tests, Grails scripting, and more recently Gradle, none of which use the static typing in Groovy. Gradle even still ships with Groovy 1.x. Unlike Groovy dynamic typing codebase, only one developer wrote the static typing codebase and it's still a little buggy. Best wait until Grails uses it before trusting it.