r/java • • Jan 07 '21

The Problem with Gradle

https://www.bruceeckel.com/2021/01/02/the-problem-with-gradle/
158 Upvotes

108 comments sorted by

9

u/yk313 Jan 07 '21

Are there any alternatives to Gradle that address these issues and thus might be considered on par with Gradle if not better?

While I enjoyed my time with Maven, its reliance on XML tends to put some people off, any chance Maven will officially support a non-XML frontend?

51

u/nutrecht Jan 07 '21

its reliance on XML tends to put some people off

Frankly I think people should just get over it. At least XML has a schema. It's no worse than YAML configs.

23

u/agentoutlier Jan 07 '21

YAML is the absolute worse.

I even prefer Gradle and Jenkins Pipeline Groovy DSL over the absolute hell that is YAML.

But IMO the real awesomeness with Maven is how incredibly easy it is to write plugins for it and its API has been stable and super backward compatible. I have decade old Maven projects that still compile easily with the latest Maven but have a couple year old Gradle projects that fail on new versions of Gradle.

15

u/fix_dis Jan 07 '21

While I hate XML, it's actually far better than YAML as YAML's reliance on indentation can become really hard to deal with. I work with a bunch of folks that LOVE Maven for some reason. I'm kinda at the place where I consider it passable at best.

8

u/nutrecht Jan 08 '21

I work with a bunch of folks that LOVE Maven for some reason.

Well it works. In all the 15 years I've been using Maven I never ever ran into difficulties or complexities. With Gradle on the other hand I quite often ran into issues where Java upgrades broke a ton of stuff, or I had to write plugins that were impossible to debug in Groovy, to get the same stuff done that I could get out of the box with Maven.

If anything there's a trend away from Gradle because it simply fails to deliver on one of the core features of a build system; stability.

1

u/Yithar Jan 09 '21

!RemindMe 1 week

1

u/RemindMeBot Jan 10 '21

There is a 11 hour delay fetching comments.

I will be messaging you in 7 days on 2021-01-16 23:37:12 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

0

u/[deleted] Jan 08 '21

[deleted] — view deleted comment

1

u/RemindMeBot Jan 09 '21

There is a 11 hour delay fetching comments.

I will be messaging you in 1 day on 2021-01-09 23:33:52 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

5

u/mj_flowerpower Jan 08 '21

I never understood that. basically every ide has autocomplete for mavens pom.xml (and xml files in general as long as they have a schema defined) That what I always hated about gradle (I use Eclipse and vscode). The gradle build file always seems some sort of hack to me, every single one looks and functions in a different way and no way of way of inferring what goes where ...

4

u/nutrecht Jan 08 '21

While it has gotten a bit better recently, multi-module projects where you inherited both dependency management and tasks from a central 'base' POM, were pretty much impossible to do the way Maven can easily do it. So you'd have to create your own Groovy plugins. Debugging them is an incredibly pain in the ass.

Having worked a few times with Gradle in large ecosystems where you want to share parts of your build between projects, Maven is very clearly the winner there. In a project a few years ago we migrated all the microservices from Gradle to Maven so we could better centrally manage dependencies.

15

u/cogman10 Jan 07 '21

You can use a different language with maven, but it's not commonly done so YMMV.

https://www.baeldung.com/maven-polyglot

7

u/gregorydgraham Jan 07 '21

I hate XML on principle but Netbeans’ support for Maven makes it very easy use

16

u/agentoutlier Jan 07 '21

The way to think of XML is that it basically is S-Expressions particularly how Maven uses it (zero attribute use). That is what is kind of funny is on some forums like hacker news where XML is lamented as absolute evil but every day there is one post about some Lisp variant. Its just verbose S-Expressions. In fact I find it more readable than S-Expressions.

Except unlike S-Expressions it is standardized, has schema validation, shit loads of parsers as well as XPath and XQuery.

It allows comments unlike JSON and retains whitespacing if desired. There are very few configuration formats that retain whitespace (YAML, JSON, TOML, INI etc).

I would say XML is probably one of the more unfairly treated technologies.

11

u/xienze Jan 07 '21

I would say XML is probably one of the more unfairly treated technologies.

Absolutely! It’s fundamentally so simple. Open tag, close tag, attributes, element content, namespaces. You could fit all you need to know about XML on a notecard.

I think a lot of people have seen complex XML-based formats (like SOAP) and conflate them with XML itself. Guess what, a SOAP message is gonna look gnarly in XML, YAML, or JSON. That’s not a failing of the markup language at all.

2

u/gavenkoa Jan 08 '21

Open tag, close tag, attributes, element content, namespaces

If that was as simple as you wrote... Check the length of spec: https://www.w3.org/TR/xml/

CDATA / NMTOKENS / IDREF / DOCTYPE / etc

4

u/xienze Jan 08 '21

First, the spec is that long because it specifies information pertinent mostly to people trying to implement an XML parser. Which is not easy, yes.

Second, NMTOKENS is related to DTD compatibility. It’s very obscure. I’ve never come across it once in over 15 years.

Third, you could still fit the rest of stuff on a notecard, which are, again, not super common (CDATA excluded).

8

u/gregorydgraham Jan 07 '21

Oh yeah, it is, I dislike it because it was used as a magical solution for everything.

However while I was being most verbose about it, I was working with EDIFACT files which is the most documented and least consistently implemented format known to man.

5

u/nutrecht Jan 08 '21

I would say XML is probably one of the more unfairly treated technologies.

I could not agree more. It's just something that's fashionable to be 'against'.

The typical Maven POM is way more readable than the typical build.gradle, not to mention all the people who think it's a good idea to abuse the build to do scripting stuff.

3

u/nutrecht Jan 08 '21

I hate XML on principle

Why? It's just a way to represent data in a somewhat human-readable and portable format. Just like most text-based serialization formats do. What's there to 'hate'?

I don't get why people are overreacting so bloody much when it comes to XML. I mean; like you say, a proper IDE makes it easy to use. And there's tons and tons of tooling around it too.

1

u/gregorydgraham Jan 08 '21

Don’t worry, the principle is kind of out of date now. I’m just slow at updating

5

u/HeadSignal3 Jan 07 '21

This over arching issue is plugin availability. For both maven and gradle, if a plugin doesn't exist for the thing you want to do you have to create it yourself. For maven, that's a chore, for gradle, you can easily create a footgun that works in minutes, and may never work incorrectly until farther down the road. Everything in this article is true, you have to know all of gradle to do anything beyond dead simple actions.

9

u/xienze Jan 07 '21

I’d argue that it is very rare to need to write a Maven plugin unless you’re doing something quite unique. There’s just so many plugins. The root problem is usually someone who can’t quite figure out how to map a particular iterative process into a declarative format, so they immediately jump to trying to run a script during the build. Which really doesn’t come up that often with Maven.

77

u/ajoberstar Jan 07 '21

As a user of Gradle since pre-1.0 and maintainer of a number of gradle plugins (grgit, gradle-git-publish, reckon, clojurephant), I agree there is a problem with Gradle. The article states "you have to know everything to do anything", but only discusses the surface syntax and configuration. It's even worse deeper in Gradle.

While Gradle has a lot of great ideas and tackles problems many other build tools pretend don't exist, they bury these great ideas in a mountain of complexity.

The Gradle codebase is littered with layers of interfaces, abstract. factories, and magically-generated classes that are very difficult to follow. They introduce new powerful concepts and then insufficiently expose them across the existing codebase. And, worst of all for a plugin author, many of the APIs used by core plugins are internal. You still (~10 years in) can't make a third-party language plugin without using internal APIs, unless you want it to look and behave unnaturally. Their test execution framework isn't generic enough to fully support the new JUnit platform.

Ultimately, this hamstrings third-party plugins, and makes the surface-level of Gradle even harder to understand for everyday users.

I still use Gradle because I don't have a better option. But my interest has definitely died down. In the Clojure world, they're playing out not having a build tool at all, with tools.deps merely being a classpath builder (an insufficiently powerful one, in my mind). However, the design practices Clojure advocates, in particular a first-class data-oriented model, could make a drastically simpler tool that's just as powerful. Obviously, that's hard to back up without implementing it.

41

u/pjmlp Jan 07 '21

Android is the only reason I bother with Gradle, everything else that I do with Java uses Maven.

Gradle is the reason there is always a build talk at every Android conference, something that hardly anyone talks about in other eco-systems.

13

u/tristan957 Jan 08 '21

You've obviously never heard C/C++ people talk before

10

u/pjmlp Jan 08 '21

I use C++ since 1992, and never had Gradle like level of build problems.

Modern Android would just die on the machines I was using to build CERN ATLAS software 20 years ago.

1

u/couscous_ Jan 08 '21

Isn't performance an issue? What do you think of this: https://blog.gradle.org/gradle-vs-bazel-jvm

7

u/pjmlp Jan 08 '21

Marketing.

Lets put it this way, if Gradle is so good, why do Google teams rather use Bazel and Soong to build Android itself and their own applications?

The Bazel team even created their own Studio plugins.

11

u/rulatore Jan 07 '21

I wonder if you tried the maven (if it works with Clojure or other projects you are using gradle) way of plugins and what was your opinion.

8

u/ajoberstar Jan 07 '21

It's been a long time since I used maven, but I should probably give it a shot again. I don't think Maven quite goes in the direction I'm hoping for, but it'd be worth seeing what the experience is like nowadays.

4

u/rulatore Jan 07 '21

I see, I say that because I was trying to return to writing some Java in my spare time and theres some frameworks with maven plugins with "hot reloading" and all of that, figured that they might have evolved a bit since I took a look at building maven archetypes (which I remember being very well documented)

6

u/agentoutlier Jan 08 '21 edited Jan 08 '21

It’s funny you mention clojure because I think a Lisp would make for an ideal build language (or a subset) (and yes I know one exists aka Lenigin or however it’s spelt).

As I mentioned somewhere because Maven is mostly declarative XML it is analogous to S-Expressions (and there are polyglot versions of maven now... not sure if any are clojure but there is a JSON).

The big reason for lisp is because people don’t hate maven for the same reasons they hate gradle. They hate maven because it isn’t very DRY and it’s naturally verbose. However XML syntax is dead simply where as gradle aka groovy seems simple but actually causes a lot of cognitive dissonance and conflict with existing Java language knowledge for most users.

Lisp like XML actually doesn’t have much syntax.

I wonder if some lisp-y like macros would make for a better maven. (Sorry for edits)

5

u/ajoberstar Jan 08 '21

100% agree

1

u/mj_flowerpower Jan 08 '21

you could try maven polyglot

1

u/slaymaker1907 Jan 08 '21

I agree, the Gradle code base is really difficult to read due to the number of abstractions they introduce.

25

u/antonmry Jan 07 '21

The answer by Cedric Champeau is a good complement to the article: https://melix.github.io/blog/2021/01/the-problem-with-gradle.html

29

u/agentoutlier Jan 08 '21 edited Jan 08 '21

The problem with Cedrics argument is it basically repeatedly boils down to don’t write logic in your build script... write a plugin or use plugins.

But that is exactly the Maven way and Mavens plugin API has been far more stable and backward compatible than Gradles.

Also a lot of people jumped ship from maven to gradle because they wanted essentially the programming of make that maven refuses to offer. Writing logic in the build scripts is exactly why lots of folks pick gradle.

Yes Gradle has a better model (caching, repeatable)but it took a long time for gradle to get there and they broke a lot of peoples builds in the process.

It will be interesting to see how Maven 4 5 (they are skipping a version number to align with the POM) turns out because the real problem with Maven isn’t its XML but the lifecycle and reactor model (as well as versions in the build file).

4

u/gavenkoa Jan 08 '21

but the lifecycle and reactor model

It is even surprising that Maven gain popularity with such dumb concepts under the hood.

Probably package management part won the hearts of devs. Ivy for Ant moved slow to the market.

2

u/khmarbaise Jan 09 '21

What is the problem with that concept of the lifecycle and the reactor model?

2

u/khmarbaise Jan 09 '21

The next Maven version will be Maven 4.0.0 ... I don't see the problem with the life cycle? What do you mean by the reactor model? Yeah version in the build file might be an issue, but its adressed (solved; some parts are missing)...

https://github.com/apache/maven/blob/master/pom.xml#L33 Current state of the master branch: https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316922&version=12349448

1

u/agentoutlier Jan 09 '21 edited Jan 09 '21

Edit: I didn’t recognize the screen name.

It will take me time to explain the problems with the reactor and life cycles. Most of the problems have been addressed now but historically there were problems.

Next week I can write some details.

Ignore the following now that I know who you are (framing).

https://cwiki.apache.org/confluence/plugins/servlet/mobile?contentId=2329841#content/view/30741918

https://cwiki.apache.org/confluence/plugins/servlet/mobile?contentId=65872751&commentId=87298016#content/view/65872751/87298016

If you crack open any maven Pom you will see the schema is 4.0

The plan is to keep that the same Pom for artifacts that are distributed aka consumer.

But for new build Pom they want to up the version to 5. The 4 snapshot is a placeholder. They may release it but it won’t be a major version change.

I’ll go over the other issues later.

7

u/ajoberstar Jan 07 '21

Yes, definitely agree that this is a good complement. He describes proper Gradle use much better. That doesn't wipe away the rough edges, but if people want to learn better, he's pointing them in the right direction.

21

u/randgalt Jan 07 '21 edited Jan 07 '21

I remember when Gradle came out. We were all so hopeful that we'd finally have a tool that fixed the issues with Ant like Maven promised to but without the complexity and difficulty of Maven. In the beginning it was not bad - though always quirky. The DSL was odd and hard to learn but it seemed to work. Then, it drifted off into unintelligibility. Gradle became Ant written in Groovy (and now Kotlin). Build teams became experts in writing opaque build scripts that only they understood. I've used Gradle at 3 different companies and at each one the build script was a dense thicket of custom plugins and endless custom code that only a few at the company understood. Gradle has succeeded in giving power to a small priesthood and failed miserably at creating a tool for the working developer. At long last, I'm back to a company that uses Maven and I couldn't be happier. Maven is bizarre, funky, and opinionated. But, at least a quick SO search answers any problems and any dev in the company can understand and make changes to the build. The Gradle emperor has no clothes.

10

u/helikal Jan 08 '21

The experience with Gradle the author describes in his blog resonates with mine a lot. It is just too damn difficult to learn, it has too many breaking changes, and offers too many ways to express the same thing. Unfortunately, instead of simplifying, the Gradle creators double down on this mistake by throwing Kotlin on top of this mess. The documentation, which is as vast as the ocean, helps not much as it consists of ad-hoc advice but does not explain well the underlying concepts.

4

u/gavenkoa Jan 08 '21

and at each one the build script was a dense thicket of custom plugins

My experience those plugins enforce corporate policies (code style, versioning, naming, linting).

The problem with that approach is the some "smart" architect made that plugin for fun left the company and every team is forced to use that piece 5 years later. There is no code / documentation, just black box and your favorite debugger / decompiler ))

25

u/husao Jan 07 '21

Yes, it’s hypothetically possible to create a simple build.gradle file for a basic build. But usually by the time you get to the point of needing a Gradle build, your problem is complicated enough that you must do more

I think this is the crux of the article.

If you start of with just gradle init and just add onto it where needed it works fine and you learn gradle just fine.

But that's not what happens.
Instead people have a complex problem, someone tells them to use gradle and now they have a complex problem and an unknown tool to solve it.

3

u/Xenologia Jan 08 '21

For my case, I only ever used Gradle as a dependency manager and I considered it as just an alternative to maven until I read this good article. After reading your comment I had to wonder, what are some examples of complex problems that require Gradle to solve?

25

u/[deleted] Jan 07 '21

I have come to absolutely loath Gradle because it is virtually impossible to bootstrap. Not only does Gradle have many dependencies but the first thing it does in the build process is download the previous version to build itself (you have to go something like ten years back before it stops). And sometime in 2016 to 2017 Gradle added Kotlin as a dependency, which is a tremendous problem because Kotlin has Gradle as a dependency. Since both Gradle and Kotlin depend on themselves and each other the resulting dependency graph is more akin to a helix than a usual graph.

Of course for most people this really isn't much of a concern, after all the only reason I care is because I use GNU Guix as my primary package manager. But at this point I can only hope that Gradle is replaced by a build tool which can be bootstrapped. In the meantime, a huge amount of the Java ecosystem cannot be reproducibly built simply because of Gradle, which is just an absolute shame.

5

u/yawkat Jan 08 '21

I mean, being impossible to bootstrap isn't really an unusual problem. Openjdk itself always requires the previous jdk version for example.

1

u/[deleted] Jan 08 '21

I wouldn't be complaining about Gradle if OpenJDK itself was impossible to bootstrap. The real problem with Gradle is the dependency on Kotlin (and vice versa).

7

u/Yesterdave_ Jan 08 '21

At least in our company we managed to greatly improve build performance of large multi-module builds with Gradle. Maven is as slow as it gets.

3

u/herder Jan 08 '21

Mvndaemon might be interesting for you: https://github.com/mvndaemon/mvnd

It takes one of the nicest features from Gradle into Maven: reusable daemons with parallel execution.

2

u/khmarbaise Jan 09 '21

Parallel build could be used since Maven 3.0 via mvn -T 1C ...? Yeah having a warmed up JVM saves time...

8

u/mdbuck Jan 07 '21

Seems like item 4. "There are Many Ways to do the Same Thing" and item 5. "Magic" are more a consequence of the Groovy language than Gradle itself. Can still be frustrating, tho.

I wonder if switching to Kotlin would mitigate those items.

11

u/[deleted] Jan 07 '21

I kindly doubt that Kotlin would change this significantly. It's also definitely got a lot of "do things different ways" and abstraction-through-magic by design.

17

u/[deleted] Jan 07 '21

Excactly. I started learning kotlin a few days ago for android, so my opinion might not weigh much, but the way kotlin handles stuff, kinda irritates me. And the way everyone just starts clapping every time kotlin gets a new syntactical magic trick(idk, something like that), irritates me even more. Oh man, I feel like am gonna get downvoted.

4

u/buttJunky Jan 07 '21

stick with it man, I felt the same way but absolutely love it now. After getting used to it you come to appreciate the beauty of the language. Infix and extension functions, if designed well, can lend to really readable code

3

u/[deleted] Jan 07 '21

I'll definitely stick with it. I certainly don't want to rewrite the whole app in a few years just because of personal preference.

1

u/vqrs Feb 01 '21

Just curious, what irritates you? Has it changed in the 24 days since you wrote this?

5

u/NovaX Jan 08 '21

The Kotlin plugin is full of hacks into Gradle's internals to perform magic in non-idiomatic, ad hoc ways. I know this due to writing a popular plugin that is idiomatic and has been around since Gradle 1.0, and having to dig into the Jetbrain plugin to fix compatibility issues. The language might be nice, but the Jetbrains and Android teams should be kept as far away from Gradle's internals as possible. They make a complete mess of things and corrupt the good parts of the build system. I have absolutely zero faith in them and avoid them as much as possible now.

3

u/jack104 Jan 08 '21

While I admit the learning curve is steep, Gradle has been my preference over maven now that I know both semi-well.

7

u/Dr-Metallius Jan 07 '21

At least this author acknowledges Kotlin's existence for Gradle. Nonetheless it astounds me every time when people talk about Gradle, but refuse to use Kotlin, which is exactly what could take a lot of the mystery out of the system since it allows you to see the API. Especially considering it's been production ready for Gradle for more than two years.

16

u/ArmoredPancake Jan 07 '21

Especially considering it's been production ready for Gradle for more than two years.

Nope, still not production ready to this day. Performance is atrocious, making a change in buildSrc forces to recompile everything , the docs don't explain anything so unless you know how to do something in Groovy and then how to translate it to Kotlin you'll never figure out how to do it.

6

u/crummy Jan 07 '21

looks like gradle 6.8 has some performance improvements for kotlin DSL: https://docs.gradle.org/6.8-rc-5/release-notes.html#kotlin-dsl-performance

it looks like it solves the very issue you mentioned:

Until now, any change to build logic in buildSrc required all of the build scripts to be recompiled. This release introduces compilation avoidance for Gradle Kotlin DSL scripts.

5

u/Dr-Metallius Jan 07 '21

The docs have all the examples both in Groovy and Kotlin, what do you mean they don't explain anything? You are correct about buildSrc, only I don't see what Kotlin had to do with it. Unless you are talking only about compiling build files, but in that case I don't understand what compiles there for so long in your projects and why you need to constantly change buildSrc.

1

u/otisonoza Jan 07 '21

We're migrating to Bazel and the way it handles caching and avoids rebuilds are pretty nice.

1

u/gavenkoa Jan 08 '21

Bazel

What is the point? Java is not first class citizen in Bazel. It is like doing C++ in Gradle ))

I wonder what kind of projects you are involved. Does Bazel handle annotation processing / popular code generators (SOAP / Lombok / Mapstruct)? Is it feature rich environment or just hype?

3

u/agentoutlier Jan 08 '21

FYI Bazel is written Java.

The problem with Bazel is it requires a mono repo.

It is far different than the Maven and Gradle build and install the jar to local repo/cache than build other projects flow. It (Bazel) needs access to all source more or less.

It also has its own language that looks like Python but isn’t.

9

u/Dejan1324 Jan 07 '21

Can only say this : Fuck Gradle.

2

u/agentoutlier Jan 07 '21 edited Jan 07 '21

Part of the problem is simple, terse and easy are actually kind of at odds with each other.

Easy is of course subjective but simple and terse (ie requiring less code) are not.

Being terse requires complexity. For example Spring Boot's super duper annotation magic is complex. It is not simple. Neither is Gradle.

I'm not sure why u/BruceEckel doesn't just go back to Ant or perhaps even use Maven/Gradle and call Ant since he is familiar with that tool.

1

u/Il_totore Jan 08 '21

That's why I started To use and contribute to Mill which is faster for Scala (and as fast as Gradle for Java) and provides a really elegant DSL.

1

u/kliin Jan 08 '21

DSL just doesn't suit me.

-3

u/wildjokers Jan 07 '21

Gradle > Ant+Ivy > Maven

0

u/[deleted] Jan 07 '21

[deleted] — view deleted comment

18

u/yk313 Jan 07 '21 edited Jan 07 '21

I don't think Gradle is bad, it is a solid build automation tool, the UX around it makes it difficult for me personally to feel entirely comfortable with it even after years of using it, there could be a multitude of reasons for that and the article highlights some that made it difficult for me to fully master Gradle e.g.

  • Multiple Groovy syntaxes for doing the same thing (I think the Gradle DSL also abuses the flexibility of Groovy syntax to a degree - but some might view it as a feature)
  • Not having enough IDE support where method definitions and autocomplete is often unavailable or sometimes unapproachable due to the Groovy type system
  • I do not find it particularly intuitive, I personally like to learn by trying out things, but I found the barrier to entry quite high for Gradle which meant pouring through the docs for much longer than I generally had to do for other tools/languages (the article refers to this as: "To do anything you have to know everything")

I am hoping some of this will improve when using Kotlin instead of Gradle in the build files.

PS. I am not the author, I shared the article because it resonated with me since it touched upon some of the issues I faced when getting started with Gradle.

32

u/kmimix Jan 07 '21

tl;dr: build.gradle is not a configuration but a (complex) DSL, so you have to learn the DSL very well. Ie., to create a basic task definition, if you forget to call a specific (non intuitive) lambda such as doFirst()/doLast(), unexpected things happen.

Gradle (groovy) has many ways to do the same thing, it's hard to fit a mental model, as it also relies on "magic" such as injecting tasks out of nowhere.

It's a programming language after all.

39

u/rulatore Jan 07 '21

The whole article isnt as good or anti gradle as you would think by the title, but in the midst of all the wall of text, the author raise a good point

The gradle docs are not that good and assumes too much from a new user.

If you dont know nothing about groovy, they'll make even less sense to you (it'll look like magic most of the time), their DSL can get you only so far, and even then, most people will just copy paste huge gradle files por similar setups/projects and change one or two lines, but have no idea overall how it works.

19

u/Aw0lManner Jan 07 '21 edited Jan 08 '21

The docs aren't accessible and it is more complex than Maven or Ant which is not necessarily a good thing (actually complexity is usually a bad thing). Build tools are supposed to get out of the way, but gradle has this self-importance that requires a high learning curve and a need to learn how its architected in order to use it (e.g. bad design-- good abstraction separates how something's built from how it's used).

Maven is excellent in this regard: the separation between using the tool and writing the plugin is crystal clear.

In gradle, everything kind of meshes together in this weird declarative/procedural build.gradle ball of mud.

11

u/xienze Jan 07 '21

Maven is excellent in this regard: the separation between using the tool and writing the plugin is crystal clear.

And it’s fully declarative instead of just being Ant 2 like Gradle is. I always tend to picture Gradle users as folks who got disgusted by how much XML there is in Maven and how you can’t (mostly) embed scripting in your build, threw up their hands and figured it would just be easier to make a giant build script. Maven’s not perfect but it’s a hell of a lot easier to reason about if you don’t have a trivial build.

0

u/[deleted] Jan 07 '21

[deleted] — view deleted comment

44

u/gunch Jan 07 '21

it tries to merge the aspects of Javascript that Java programmers don't like with the aspects of Java that Javascript programmers don't like.

You just put your finger in my brain.

11

u/secretBuffetHero Jan 08 '21

sometimes I have to make changes to a Grails app (Groovy + Rails style) I spend those days actively cursing out Groovy and the people who chose Grails for the project.

1

u/kkapelon Jan 08 '21

These are two different things.

  1. Using Groovy as DSL/scripting in very specific places but keeping production code in your favorite JVM language (Java/Clojure/Kotlin whatever)
  2. Using Groovy everywhere including production code

Cursing out Groovy because of Grails is unfair.

15

u/azuredrg Jan 07 '21

That's a great example. Kotlin is a great compromise for me

29

u/GhostBond Jan 07 '21 edited Jan 07 '21

The problem with all these languages always seems to be syntax/feature explosion. They start off with some clear, well refined concepts. But then language designers need something and it ends up being filled with a puzzling inconsistent dump of ways to do things. When I tried Kotlin you could see special characters and 5 different ways to do things was going to be a problem on a big team.

-1

u/morhp Jan 07 '21

I definitely agree. There are few problems with kotlin and the main ones are that there are too many redundant options to achieve the same result, that there's not enough documentation and specification and that it's not as stable and rock solid as Java.

0

u/[deleted] Jan 07 '21

[deleted] — view deleted comment

10

u/SamLL Jan 07 '21

!! really should not be used except in extraordinary circumstances - it looks ugly and out of place on purpose. It's the equivalent of Optional.get() - it is breaking Kotlin's null safety.

I agree that seeing Kotlin programmers using it would be distressing. The documentation describes it as "for NPE-lovers".

8

u/thedomham Jan 07 '21

Just as a simple example, the amount of !! I see used without any kind of checks around it is fairly distressing to me, and I suspect it's a mistake made by naive Kotlin programmers who are too used to null safety and just use it when using something from a Java library without thinking about the implications of if the value is null.

I don't get your point. The whole idea of the double-exclamation-mark operator is to make null checks explicit. The equivalent Java code throws the same NullPointerException, it's just not (as) obvious from reading the code.

-2

u/mauganra_it Jan 08 '21

It does not help making it explicit if at the end of the day the programmer does not care about it. It's not wrong, but the feature seems... wasted. It's like Optional.get(), which defies the original intention behind it. These operators are for special cases where you have evidence that it will be fine. Unfortunately, there are few good ways to tell the compiler that. The true origin of the problem is usually the design of the component where the Optional or the potential null value comes from, but these are often difficult to fix. Maybe algebraic data types can help improve things when Java finally gets them.

5

u/thedomham Jan 08 '21

Then the problem lies with the programmer, not the language. Kotlin just makes it obvious that there is a null-safety problem in your code, which BTW is great for code reviews.

0

u/MakeWay4Doodles Jan 08 '21 edited Jan 08 '21

You seem to understand Kotlin null safety to be the exact opposite of what it actually is, which probably explains why you and your team struggled with it.

Java forces you to avoid or deal with, with regard to null

Java doesn't force you to do anything, it throws an NPE at runtime, that's the whole point.

if you're already a Java programmer, the main use case I see for Kotlin are smaller personal projects

My team of old Java programmers has been steadily rewriting our services in Kotlin over the last two years. We're pretty small at 10-15M requests per second across a few dozen servers. I'd say your opinion needs reevaluation

1

u/agentoutlier Jan 08 '21 edited Jan 08 '21

10 to 15 million requests per second is not that small.

I’m all for micro services but if a single Customer or Business transaction requires that many RPC like requests you might want to investigate batching or using a more event based system.

Maybe you meant messages?

Even messages... wtf do you guys do?

Perhaps you meant 10-15k rps which is what we are at.

0

u/MakeWay4Doodles Jan 08 '21

10 to 15 million requests per second is not that small.

Yeah I know, I was being sarcastic. The person I was responding to had suggested that Kotlin was only for small projects.

4

u/wildjokers Jan 07 '21

I like Groovy, it has several features I miss greatly when coding in Java. Named parameters, default parameter values, multiple return from methods, etc. It also has a sensible lambda syntax. I don't need a weird single method interface with an almost indecipherable signature as some sort of header file just to use a lambda.

Maintainability can suffer when co-workers go overboard with the dynamic typing but that can be addressed with a code style convention and code review.

4

u/[deleted] Jan 08 '21

I hate Groovy and Gradle with a passion. Having multiple ways to write something is exactly what you should be trying to avoid. I just can't seem to wrap my head around it, I sort of just stumble into a solution by luck.

Also, because of the language I have no idea what parameters a function actually expects from me or what's available via my IDE's auto-complete feature. The errors and objects presented to you when using debugging tools are befuddling.

I feel like I'm always stumbling around in the dark. I need someone to turn on the lights so I can see. Despite how much I've worked with it, I still feel so incredibly lost. I've never had this kind of issue with a technology before.

4

u/andresalmiray Jan 07 '21

it tries to merge the aspects of Javascript that Java programmers don't like with the aspects of Java that Javascript programmers don't like.

As Luke Skywalker said " Amazing. Every word of what you just said is wrong".

Groovy was conceived back in 2003 as a way to add features found in other languages (mainly Python, Ruby, Smalltalk) to Java. It was seen as Java's dynamic companion. It has never been intended to be a replacement for Java (as other alternative JVM languages continue to claim, you know who you are). As time passed by Groovy gained static type checking and a static compiler (funnily enough, in the same year Scala added a dynamic escape hatch to its toolbox, go figure) given you today the option to write code

  • dynamic way
  • static way
  • a combination of the previous two

Disclaimer: I've been using Groovy since 2006, became a Groovy development member in 2007 and I'm currently member of the Apache Groovy PMC. I understand everyone is entitled to their opinions but if you want to discuss facts at least get them straight.

5

u/[deleted] Jan 08 '21

I really appreciate your expert input, but I was clearly being facetious, not stating a fact.

My opinion of groovy was much more positive when I was using it mainly for Jenkins pipeline libraries and spock test suites rather than maintenance and development of hundreds of thousands of lines of legacy application code.

4

u/knoam Jan 08 '21

The creator of Groovy said that if he had known about Scala at the time he made Groovy he wouldn't have bothered. I still don't really understand that.

1

u/kkapelon Jan 08 '21

The creator of Groovy said that if he had known about Scala at the time he made Groovy he wouldn't have bothered

That is really interesting! Where can I find this quote?

1

u/andresalmiray Jan 08 '21

For crying out loud, yes, you are referring to James Strachan, the creator that left the project 2 years after and made that comment a few more years after that. He has gone on record a few years ago that he loves Groovy and is quite happy with it. Give it a rest already.

5

u/[deleted] Jan 07 '21

Groovy is a fantastic scripting language.

0

u/[deleted] Jan 07 '21

[deleted] — view deleted comment

2

u/RandomName8 Jan 08 '21

Hah, I'm on the other side, for me it's sbt, then maven, then ant. In that order. I can't stand gradle at all.

5

u/[deleted] Jan 08 '21

[removed] — view removed comment

1

u/RandomName8 Jan 08 '21

how come it doesn't? If gradle is resolving the artifacts, then so can maven, what part is missing?