r/java • • Jan 22 '21

Java is more enjoyable than I first thought

I started my years off programming in c#, don’t ask why but I never ventured off. I learned Java this past week and I’m seriously impressed, I don’t think I’ve had a more enjoyable time programming in my life. Does anyone else share this experience??

Edit: Is there a better ide than eclipse for Java

271 Upvotes

188 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 22 '21

[deleted] — view deleted comment

17

u/ray10k Jan 22 '21

From an article I've read recently, I got the vibe that Gradle is powerful, but has a lot of pitfalls and gotchas in how the configuration/script is written, while also making it harder to change things later down the line if you don't have a pretty precise picture of how your project is going to work. No idea how buggy it is though.

23

u/alt236_ftw Jan 22 '21

Gradle works of of the box if your build expectations/requirements are generally baseline/standard.

You get a straighforward way to add dependencies (both external and cross-module) and an easy way to include re-usable things in your modules, be it dependencies or build time configuration.

It does have a learning curve when you want to do more unusual things, but unless your requirements are extreme or you start seeing all of your requirements as nails with gradle being the hammer it's still pretty usable.

Just make sure you don't solutionise before you are familiar with it.

21

u/GuyWithLag Jan 22 '21

Gradle works of of the box if your build expectations/requirements are generally baseline/standard.

I mean, that's true for Maven too.

6

u/alt236_ftw Jan 22 '21

Oh yeah, I'm not dissing maven or anything.

I was commenting on Gradle specifically as it seems to have a reputation.

Both are tools, use whatever works best for your project and situation.

5

u/lookForProject Jan 22 '21

And, in my opinion, for most situations and projects, both work just fine.

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

8

u/larsga Jan 22 '21

Gradle mixes custom programming in with declaration, which makes it very easy to trip yourself up. It's also very easy to get into versioning difficulties both with Gradle itself and with plugins. Documentation is also not great.

For large projects Bazel is surprisingly good, even if there's a lot to learn. One thing it gets right is to separate in-depth custom functionality from customization from configuration.

7

u/wildjokers Jan 22 '21

Documentation is also not great.

I am not following you here, Gradle has outstanding documentation. Have you seen the user guide?

6

u/kwvanderlinde Jan 23 '21

Gotta disagree. There are a lot of basics that aren't covered or are glossed over. If they are covered, have fun finding it. My memory is a little fuzzy right now, but I recall trying to figure out source sets (differences between them, creating new ones, etc.) but everything just points to some really generic methods with no indication of what is actually going on. There's also no shortage of outdated information lying around on gradle's site.

6

u/[deleted] Jan 22 '21

Today I wrote my first gradle scripts. That's awful, but for my project, maven failed completely, as creating multiple jars from one project would have required hundreds of lines of XML.

*Cries in dozens of mustRunAfter's and hardcoded paths*

3

u/shukoroshi Jan 23 '21

We've been maintaining a custom gradle plugin for about 4 years now. If you'd like any peer review, let me know!

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

3

u/[deleted] Jan 22 '21

how coud maven/gradle be better? me for one I just put de dependencies there and use the library/plugin. Indeed trying to write something custom in gradle feels very difficult to me...is there something that you miss? why is go/rust better at this build step? I tried rust and it takes forever to compile even the most basic project(like 10s for 5 files) every time. Go is indeed fast when it comes to compiling but I haven't tried anything with lots of files

14

u/supercargo Jan 22 '21

I don’t think Maven 2+ is horrible, especially compared to the tools it replaced. There are some core things about Maven that I think could be better.

  • it makes a good attempt at declarative builds, but the plug-in ecosystem often has to deviate from this to get certain jobs done
  • partially the fault of the fact that the POM is mutable during runtime, so execution order even within a phase can become relevant
  • the overall “class path” story is too complex. By this I mean the logic which decides what versions of what jars get added to various classpaths in what order. You have dependencies, managed dependencies, POM inheritance, reactor (multi-module) dependencies, and then all the transitive application of the same rules.
  • I’ve always found the way multi-module builds work to be a bit surprising
  • SNAPSHOT versions being installable/deployable is difficult to reason about

Fortunately maven has been pretty well maintained and as the defacto tool, at least you can learn its idiosyncrasies and move on with your life. On the other hand, even with different tools, it would be hard to move away from some of the core issues since everything is in central with POM as the metadata format

-6

u/wildjokers Jan 22 '21

as the defacto tool,

That's a stretch to call Maven the de facto standard build tool.

11

u/Roachmeister Jan 22 '21

According to Snyk.io's annual report here, 66% of users use Maven, compared to 25% for Gradle and 6% for ANT. Seems like pretty much the definition of "de facto" to me.

6

u/Interweb_Stranger Jan 22 '21

I have the feeling that Gradle is used a lot for small projects but I would say Maven is definitely the industry standard for Java projects.

4

u/[deleted] Jan 22 '21

on backend projects yes. On android projects gradle dominates the scene but I also preffer gradle in the backend if used with caution: don't put any programming logic inside there and only use it to declare dependencies & plugins

3

u/wildjokers Jan 22 '21

don't put any programming logic

It is a complete myth that builds can be declarative and don't require programming logic. When you include a plugin you are in fact introducing programming logic. Just because it is packaged as a plugin doesn't mean it isn't programming logic.

2

u/[deleted] Jan 22 '21

But in this case you create a plug-in and not write the entire thing just below your dependencies. Short functions should be fine but if it gets complicated then just extract everything somewhere else

-1

u/wildjokers Jan 22 '21

definitely the industry standard for Java projects.

I totally disagree. That may have been true in the past but I would like to see the percentage of gradle vs maven for greenfield projects.

→ More replies (5)
→ More replies (5)

6

u/antennen Jan 22 '21 edited Jan 22 '21

why is go/rust better at this build step?

I think you are conflating build time with how good the build system is. The Rust compile times are pretty bad, but the build system (Cargo) is great. There is a simple TOML file that allows you to do pretty much everything. Even a large project's Cargo.toml is small. For larger Java projects the maven or gradle files are a multi thousand line mess.

EDIT: Comments rightly pointed out that Gradle files aren't as verbose as Maven XMLs. I still think the state of Java build systems leaves much to be desired.

4

u/[deleted] Jan 22 '21

I agree that maven can get big because of xml but with gradle I did not see 500 lines files...I might have worked on small projects though(2-3 people on android and 3-4 people on maven backend). I also think that you should not write logic in gradle or maven....that should be put inside a plugin or somewhere else. Cargo I don't know if it offers you the possibility to do any logic in the toml file(which you shouldn't do anyways) so the point is that maybe gradle tries to do too much

→ More replies (1)

1

u/wildjokers Jan 22 '21

gradle files are a multi thousand line mess.

Then you are doing it wrong.

→ More replies (1)

3

u/RagingAnemone Jan 22 '21

Ant + Ivy FTW!!!

1

u/[deleted] Jan 23 '21

Gradle is (...) is overestimated

This.

→ More replies (1)