from Hacker News

Mill: A fast JVM build tool for Java and Scala

by 0x54MUR41 on 10/28/24, 3:56 AM with 162 comments

  • by lihaoyi on 10/28/24, 11:15 AM

    Author here! Hope you take a look at the project and find it cool. There's a lot of interesting stuff here. In particular, the Video linked on the landing page is a great intros from a Java developer point of view, and the following video is a great intro from a Build Tool Architect point of view:

    * https://www.youtube.com/watch?v=UsXgCeU-ovI

    While Mill is focusing on JVM for now, it is very extensible and I have a strawman demo of adding a Javascript toolchain in ~100 lines of code https://mill-build.org/mill/0.12.1/extending/new-language.ht...

    For those of you who want to learn more about the design principles and architecture of Mill, and what makes it unique, you should check out the page on Design Principles which has links to videos and blog posts where I elaborate on what exactly makes Mill so different from Maven, Gradle, SBT, Bazel, and so on:

    * Mill Design Principles https://mill-build.org/mill/0.12.1/depth/design-principles.h...

    I've mentioned this in a few places, but the comparisons with other build tools are best-effort. I have no doubt they can be made more accurate, and welcome feedback so I can go back and refine them. Please take them with a grain of salt

    I'm also trying to get the community involved, so it's not just me writing code and running the show. To that end, I have set up a bounty program, so pay out significant sums of money (500-2000USD a piece) for people who make non-trivial contributions. It's already paid out about 10kUSD and has another 20kUSD on the table, so if anyone wants to get involved and make a little cash, feel free to take a shot at one of the bounties! https://github.com/orgs/com-lihaoyi/discussions/6

  • by sireat on 10/28/24, 11:40 AM

    Just a note that the author Li Haoyi is a fantastic contributor to Scala community.

    He has written multiple useful libraries. Out of many JSON libraries, his one was the most intuitive and practial.

    His book is excellent too. I bought it when it came out. It is worthy of a plug: https://www.handsonscala.com/

    I miss working on Scala projects. Sadly I rarely see new ones these days.

    Does IntelliJ plugin finally work on Scala 3? About 2 years ago it was half broken.

  • by spuz on 10/28/24, 8:51 AM

    A build tool that is not only fast but configured in a type safe way sounds great. I really like this quote from the "Why use scala" part of the documentation:

    > Most developers using a build tool are not build tool experts, and have no desire to become build tool experts. They will forever be cargo-culting examples they find online, copy-pasting from other parts of the codebase, or blindly fumbling their customizations. It is in this context that Mill’s static typing really shines: what such "perpetual beginners" need most is help understanding/navigating the build logic, and help checking their proposed changes for dumb mistakes. And there will be dumb mistakes, because most people are not and will never be build-tool experts or enthusiasts

  • by mrudolph22 on 10/28/24, 4:46 PM

    I gave Mill a try earlier this year. My hope was to escape the nightmare that is Gradle, which I've been using for many years. Mill sounds great in theory (except for the Scala DSL). Unfortunately, I couldn't get a basic Java build to work in half a day, even though I have (admittedly rusty) working knowledge of Scala. It was one obscure error after another. My conclusion was that Java support isn't ready. There was also very little documentation on how to build Java.

    In my opinion, using a GPL as the build language of a polyglot build tool is a dead end, both for technical/usability reasons and because the ensuing language wars can't be won. I'm looking forward to the day when a build tool embraces a modern config language such as CUE or Pkl.

  • by carrotsalad on 10/28/24, 4:16 PM

    Mill looks interesting, but, _from a Java development perspective_, it has the same fundamental challenge as Gradle (and most other build systems), which is that its config language _is something other than Java_. That means there's a significant cognitive burden to understand and manage something that one hopes to not have to think about very often.

    I find that the pain I experience with Gradle isn't usually about how to do something clever or customized etc, but instead it's when I haven't thought about Gradle syntax in the last 3 months since everything has been silently working, but now I need to figure out some small thing, and that means I need to go re-learn basic Gradle stuff - whether it's groovy, Kotlin, or some aspect of the build DSL - since my mind has unloaded everything about Gradle in the meantime.

    Simplifying the semantic complexity of a general purpose build system will always help, but the most useful thing for me would be if the configuration for a Java build were to natively use the Java language directly.

  • by k3vinw on 10/28/24, 11:52 AM

    The thing that’s great about maven is its declarative nature. You can declare goals and profiles for whatever you need the build system to do.

    The main appeal that I can see from mill over maven is the power of dynamic programming over static xml files. Maybe good lsp/ide support will make managing a build system like this bearable?

  • by cryptos on 10/28/24, 10:31 AM

    The comparision with Gradle is not up to date. There is stated that you would end up in an untyped mess of Groovy build files, but statically typed Kotlin files are the default for quite some time now in Gradle! https://mill-build.org/mill/0.12.1/comparisons/gradle.html
  • by potamic on 10/28/24, 9:12 AM

    What tends to be complex about build requirements that necessitates special purpose tools? Golang seems to be doing fine with just go build and go test. What else are people doing with gradle/maven that requires static typing, DAGs, plugins etc.?
  • by iamcalledrob on 10/28/24, 9:37 AM

    It's not clear to me how this is better than Gradle. And I hate Gradle.

    At first glance, Mill looks like it has many of the pitfalls of Gradle: - Plugins: Creates the temptation to rely on plugins for everything, and suddenly you're in plugin dependency hell with no idea how anything actually works. - Build scripts written in a DSL on top of a new language: Now I have to learn Scala and your DSL. I don't want to do either! - Build scripts written in a language that can be used for code too: Versioning hell when the compiler for the build system needs to be a different version to the compiler for the actual project code. See: Gradle and Kotlin

  • by PaulHoule on 10/28/24, 4:49 PM

    Speed wins for dev tools.

    I had worked out that math for “like pip but actually works” but few people were conscious that pip didn’t quite work reliably for large and complex projects — I didn’t think it was possible to sell it.

    Uv won hearts and minds because it was uncompromisingly fast: people did not really care that it had a correct resolving algorithim or that is was really reliable because it is not written in Python and thus can’t trash it’s own dependencies (maybe a solvable problem in that the build tool can have its own virtualenv but isn’t it nice to for your package manager to be a binary that can’t get dependencies screwed up no matter how hard the users try?)

  • by TeaVMFan on 10/28/24, 7:16 PM

    It's great to see continuing innovation in the Java space!

    One tool I've been using to speed up maven is mvnd, the maven daemon. It's a drop in replacement for mvn with impressive speedups.

    https://github.com/apache/maven-mvnd

  • by thefaux on 10/28/24, 6:37 PM

    The last time I checked, sbt was much faster than mill for incremental builds. Mill has a faster cold startup time, but sbt uses classloader tricks to reuse jitted classes so that it doesn't have to reload the scala standard library. When running tests continuously and rerunning on save, sbt was much faster than mill for equivalent projects. I haven't tested in three years or so though. But I would encourage people to make a simple project in sbt and mill and run `sbt ~test` and compare it to `mill -w test`. In the past, I found that after a few iterations, sbt could respond to changes in a few hundred milliseconds while mill would take multiple seconds to retest the same code. That difference really adds up when you are iterating on a problem.

    That said, I have come to believe that the jvm is a bad platform for a build tool. Everything that touches the jvm becomes bloated and slow, particularly for startup. I no longer write scala because of my frustration with the bloat (and scala adds its own bloat on top of the jvm).

  • by pnathan on 10/28/24, 3:40 PM

    I've used mill for some Scala projects in the past and I give it 5/5.
  • by msl09 on 10/28/24, 2:38 PM

    Nice try, I'm still not going to write scala code.
  • by Raydat on 10/28/24, 10:07 PM

    Big fan of mill! (Coming from maven, Gradle and SBT) - the 1:1 mapping of build tasks to output files is the big one for me as it makes understanding other people's builds so much easier going through it step by step
  • by jiehong on 10/28/24, 10:54 AM

    Why not compare it to bazel/pants/buck2 as well?

    Mill seems to have taken some inspiration from those as well.

  • by BillLucky on 10/30/24, 1:39 AM

    Sounds great!
  • by whoodle on 10/28/24, 3:29 PM

    Sorry to hijack this thread a bit, but I currently work at a Scala shop and have grown to like writing it. I worked at Clojure heavy place previously. This tool looks neat.

    Has anyone at the senior level recently moved on from Scala to other languages recently? Any issue finding jobs or learning the new role?