r/java • • Jun 01 '24

What java technology (library, framework, feature) would not recommend and why?

165 Upvotes

464 comments sorted by

View all comments

124

u/jevring Jun 01 '24

Gradle. Having an executable build definition, rather than a declarative one, makes the build way more complicated than it has any right to be, which makes importing the project slower and harder to work with.

5

u/Practical_Cattle_933 Jun 01 '24

Gradle is 100% declarative. You can add some logic to change that declarative configuration (which gets cached the first time you use it), but otherwise gradle has a completely static, correct view of the project.

Hell, it is actually more accurate than Maven in this regard, there is never a case that you would have to do a clean install, unlike with Maven.

This is a grave misunderstanding of the underlying concepts.

15

u/rest_mah Jun 01 '24

My personal journey with Gradle:

  1. hey it looks very nice when I define a Java project and a few dependencies

  2. wow! I can code my own build logic into the build!

  3. yeah! I've added own more script into the build to solve a rarely occurring need!

  4. oh noes my build is very hard to maintain and bugged

  5. get rid of unnecessary scripts/tasks - properly design and test the few I still deem useful

  6. hey it looks very nice

4

u/Practical_Cattle_933 Jun 01 '24

Isn’t that how any project is, basically?

Nonetheless, sometimes you just can’t change the requirements and do need some flexibility - e.g. integration of some other programming language, etc. gradle is absolutely one of the very few tools that you can use here (other being.. bazel? Not much else). Something like go’s build tool is only made for go and can’t deal with stuff like this.

3

u/rest_mah Jun 01 '24

Isn’t that how any project is, basically?

Indeed. And that's why I now approach my Gradle build(s) like a project and not simply using it a big bucket of throw-away scripts.

Gradle allows one adding a lot of things. Its flexibility is of its big quality. It's also easily misused and then an issue. I don't know if I would argue whether it's the fault of the tool, or the fault of the users, or both.

6

u/RandomName8 Jun 01 '24

Gradle is not 100% declarative.

Let's not stretch the meaning of declarative to be whatever we want it to be. Gradle is not declarative, it cannot be because it lets the imperative language where it bases its configuration syntax to imperatively mutate the configuration runtime. Take a look at the wikipedia entry on declarative programming.

Much like with function purity, it's only globally useful when you can ensure the entire system is pure, if something isn't, then you really throw away all guarantees.

This means, without a doubt, that the only way to understand a gradle build is to read every single gradle file "sourced" (via includes or whatever) in the configuration, because anything at any point can, as a side effect, mutate the way the dsl works (a method can exist or not entirely based on the order of lines interpreted); it eliminates local reasoning, and it happens in any non trivial gradle build.

I've followed gradle definition examples from the official plugin documentations to the letter without doing code and it would still fail due to the order of declarations, took me forever (because obviously nobody documented this) to know that if things don't evaluate in order, it wouldn't work.

 

At least gradle's groovy dsl is syntax soup resolved at runtime, very mutable, and very imperative (variables and methods will "pop up" in some types based on the order of lines executed), and its cache breaks if you even look at it funny.

If anything, even though I don't think you can be "partially declarative" (it's either you are or not), It's like 20% declarative being generous.

→ More replies (1)
→ More replies (3)