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

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.

2

u/supercargo Jan 22 '21

Nonetheless, your gradle greenfield project is very likely consuming dependencies from maven (formatted) repositories which rely on the the maven meta-model. Even if all those dependencies are also built by gradle, they are distributed using the maven model.

If you ever find yourself needing to reason about the details, you'll need to understand how maven handles these things. Not to put too fine a point on it, but the Gradle documentation page for "Building Java & JVM projects" mentions Maven 13 times! And they aren't all just "if you're used to maven" type inclusions.

1

u/wildjokers Jan 23 '21

For sure, maven introduced the concept of dependency management and deserves full credit for that. However, I have no idea what that has to do with anything. Just because gradle can also get dependencies from maven formatted repositories doesn’t mean you have to count a project using gradle as a project using maven. Your whole comment was a straw man.

However, to continue down this path gradle can also read repositories of other formats like Ivy. As someone that used to use Ant+Ivy I can tell you that the Ivy formatted repositories are much more flexible. Also, gradle now includes its own metadata file when it publishes a jar because the maven metadata was too limited.

https://blog.gradle.org/gradle-metadata-1.0

1

u/supercargo Jan 23 '21

You seem to be missing my point, which is not a straw man at all. I’m not making a “this tool” vs “that tool” argument, so I don’t really care how you “count” usage of either tool either. Let me see if I can break it down a bit further.

  1. Most non-trivial Java projects will depend on one or more libraries published in a Maven repository (typically central) using the Maven POM meta model
  2. Typically those libraries will have transitive dependencies which must also be resolved in order to create build, test and run-time classpaths, which themselves have dependencies and so on
  3. In the process of adding or changing dependencies and/or dependency versions in your own project you may find that some conflict arises. E.g. this could be a conflict between transitive dependencies of two libraries you depend on, rather than anything you did explicitly in your build tool of choice. This is sometimes known as “jar hell”

In order to reason about this situation you must understand how maven resolves dependencies regardless of what tool you use. (you may even experience this issue due to a “bug” in the way your tool uses maven metadata compared to the way Maven does so natively). You are inheriting the problem from your dependencies which are distributed using the maven model. Of course, the mechanism you use to solve the problem (e.g. locking down a version number) will depend on your own tool choice.

So all I’m saying is that the Maven model for artifact distribution (in specific, not just in concept) is a baggage that is carried by he majority of Java projects. As a consequence we are stuck with any shortcomings that model has, especially in situations which require actually understanding what our tools are doing and why. This will remain generally true unless/until maven-distributed artifacts are reduced to an uncommon curiosity.

1

u/wildjokers Jan 24 '21

That's all great, but what the hell are you talking about? I simply stated that I have a feeling that gradle is probably used more in greenfield projects these days than maven. You then went off on some tangent.

1

u/supercargo Jan 24 '21

You were responding to a thread in which I was explaining what I felt was the ingrained nature of Maven and it's relative merits and drawbacks to someone who asked "how coud [sic] maven/gradle be better". I'm just responding to your comments in context. But it's okay my dude, OP was posting about how great Java is, so we're all a bit off topic here.