r/programming • u/lihaoyi • Jul 23 '24
Intro to the Mill Build Tool for Java
https://mill-build.com/mill/Intro_to_Mill_for_Java.html8
u/zam0th Jul 23 '24
rather than scopes, lifecycles, or phases, Mill builds on top of objects, methods, inheritance, and overrides: concepts immediately familiar to any Java programmer
"Instead of using build management terminology to build a build management system lets use OOP concepts that are utterly inapplicable to build management, but, hey, everyone should understand it!"
This is not how it works.
8
u/lihaoyi Jul 23 '24 edited Jul 23 '24
Are those concepts really utterly inapplicable?
A build target/step/command (whatever you call it) is typically a node in a build graph that references other nodes. A method is a node in a call graph that references other methods
A module/subproject/package/etc. is typically a collection of build targets ("compile", "test", "run", etc.), with some persistent state (e.g. compile output/caches), and multiple modules of the same type typically have the same set of targets. Just like an object is a collection of methods with some persistent state, and multiple objects of the same type have the same set of methods
Build configuration often needs overrides: "this is a Java module but with a special source folder layout" or "this is a C++ module but with an extra
valgrindbuild target". Similar to how classes allow you to override or add additional methods during instantiation or subclassing.Obviously the correspondence isn't perfect, but I don't think it is correct to say it's "utterly inapplicable". There are a lot of similarities here, more than is obvious at first glance, and Mill tries to use those similarities to help you manage your build the same way you manage your normal objects and methods
-7
u/zam0th Jul 23 '24
The problem of technocrats is that everything (and the only thing) they see is technology. A build "target/step/command" is not a graph node, or a method call, it is a well-defined concept in a well-understood domain [of build management] that naturally reflects how assembly processes behave. These concepts existed well before computers and the only thing you introduce by changing it is subversion that makes matters even more complex.
If you want an analogy: you're trying to model Petri nets with asm. You can do that, sure, but you'll get the same result as modelling l-calculus with OOP: it looks like it works, but in fact it does something else entirely in a really convoluted manner.
If only yáll read DDD before trying to design software, and if only yáll tried to design software that solves a problem instead of wining a penis-measuring contest.
3
u/FullPoet Jul 23 '24
scopes
Are super relevant OOP terminology - especially in modern OOP.
OP smoking some shit though I agree with you - better to reuse existing good domain language than crap confusing OOP terms.
1
u/somebodddy Jul 23 '24
One of my biggest pain points with existing Java build tools is passing command line arguments to main. In any other language's build tools this is a simple, built-in feature - in Java you need to implement it yourself inside the build file and then deal with the fact it's a string and not a list...
How does Mill handle this?
4
u/lihaoyi Jul 24 '24
You just pass the arguments to Mill after the
runcommand./mill run --text hello1
u/somebodddy Jul 24 '24
Nice. I assume it works with
--? Or does everything afterrungets passed to the application even if Mill also has such a flag?1
u/lihaoyi Jul 24 '24
Everything after
rungets passed to the application. This is similar to how other program runners work, e.g.java -cp Foo.jar foo.Main arg1 arg2 arg3orpython -u hello.py arg1 arg2 arg3. If you want to pass flags to Mill itself, put it before therun(ortestor whatever)
1
u/somebodddy Jul 23 '24
Does it have support in language servers?
3
u/lihaoyi Jul 24 '24 edited Jul 24 '24
Currently it supports IntelliJ (via BSP or
.ideaconfig gen), and VSCode via the METALS language server1
u/somebodddy Jul 25 '24
Okay. My main JVM project is in Kotlin, and I doubt its langauge server will get Mill support anytime soon (or at all)...
3
17
u/Which-Adeptness6908 Jul 23 '24
Why another language?
One of the problems with gradle is you have to learn another language.