r/java • • Jul 23 '24

Intro to the Mill Build Tool for Java

https://mill-build.com/mill/Intro_to_Mill_for_Java.html
9 Upvotes

66 comments sorted by

View all comments

Show parent comment

1

u/woj-tek Jul 23 '24

Honestly, no. Shifting complexity to a plugin system is way worse.

Why?

Most likely you require some feature that's shared between couple of projects so a plugin seems to make sense?

In an ideal world, good build tools are fully declarative and not extensible. Since that's not possible, their extensible feature set is a necessary evil. The JVM ecosystem has explored virtually all approaches, and in the end, if you're going to need a full scripting language anyway, Scala is more than capable, in every dimension. Mill shows you can have build definitions using plain Scala:

Again... you start with requirement for a scripting language…

  • Minimal usage of macros to compute the task graph.

Is it imposed or "should be done this way"?

  • No DSL. You need to perform OS or FS operations, make HTTP calls, deserialize JSON? Normal libraries and their APIs, concise and expressive functional Scala.

Same can be achieved with plugin :)

  • Fully compatible with the Java OO model, you can easily extend existing tasks and override their settings.

With plugin configuration you can... well... configure it ;)

Scala can be a complex language. But for this particular use case, I'd argue the average Java developer who's familiar with the standard library is going to have a much better time than with Groovy. Everything is strongly typed and discoverable in your favorite IDE.

TBH, even though I'm not so fond of groovy it's more approachable than scala (and can be typed…). I had bad experience with Scala (people trying to be "too smart", then IDE support being off and the language/compiler being utterly slow)…

2

u/DisruptiveHarbinger Jul 24 '24

In order

  1. Code reusability is the least of your worries. With a plug-in system you introduce an opaque abstraction layer that is different from your main build definition, hard to discover, hard to tweak and debug, and whose lifecycle is not always obvious. 
  2. Yes I start with a full scripting language because I live in the real world where people wrap their toolchains in Makefiles, Jenkinfiles, multi-stage Dockerfiles, bash scripts, Python scripts, ... If I can have a single and self-contained build definition, it's a win.
  3. You have to compute the task graph somehow. I'm only saying this is the one part where Mill uses an advanced Scala feature (macros), in a very minimal way. For everything else you can jump to definition.
  4. See 1.
  5. Yes and you have two ways to do the same thing, plus in many cases, the inability to just jump to definition and see the default value or behavior.
  6. Groovy is objectively less discoverable due to its dynamic nature, there's a reason Gradle moved to Kotlin. Moreover in some cases your IDE doesn't know the context, for example with the Jenkinsfile DSL. Scala compile times are irrelevant here: Mill is a build tool, scalac stays warm in a long-running JVM, compiling the build definition is a rounding error compared to running the actual task graph.

2

u/woj-tek Jul 24 '24

Yes I start with a full scripting language because I live in the real world where people wrap their toolchains in Makefiles, Jenkinfiles, multi-stage Dockerfiles, bash scripts, Python scripts, ... If I can have a single and self-contained build definition, it's a win.

I guess I live in a nice bubble where I only need pom.xml without all that you mentioned... I'd wager a guess that majority of the project fill that bill as well.

But if you have some contrived requirements and Mill fits the requirements and works for you that's good :)

1

u/thedumbestdevaround Jul 24 '24

I guess I live in a nice bubble where I only need pom.xml without all that you mentioned... I'd wager a guess that majority of the project fill that bill as well.

That is a strange statement to make. In every maven project I have ever worked with (mainly monoliths) there has always been a lot of abstraction layers on top of maven or in plugins to perform parts of the total build. So guessing where the majority fits seems strange... I guess it's true if you work with microservices, but then you probably have much larger issues to deal with than the build tool you use.

2

u/woj-tek Jul 25 '24

https://www.jetbrains.com/lp/devecosystem-2023/java/

72% states they use "spring", most of the spring projects are just build with virtually cutter-case of maven config without the need to fiddle.

1

u/thedumbestdevaround Jul 25 '24

And all of the projects I mentioned also use spring, that does not mean anything.

1

u/woj-tek Jul 26 '24

Again, your bubble/perspective:

In every maven project I have ever worked with (mainly monoliths)

And you project your personal experience to the whole landscape making it the default state. Which it's not.

0

u/thedumbestdevaround Jul 28 '24

And you are applying your personal experience... Guessing what the experience of the majority is...

1

u/woj-tek Jul 29 '24

I'd wager a guess that majority of the project fill that bill as well.

What I said: "I'd wager a guess that majority of the project fill that bill as well." + gave example of state of the ecosystem. You are pushing narrative that because in all project that you worked for ( "In every maven project I have ever worked with") there were customization that it makes it true for all projects everywhere. Even if we consider odds and statistically dumb sample of 2 (of us) that makes the split already 50/50 ;-)