10
In defense of Makefile
(jeferson.me)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
Make is pretty jank. I wouldn't defend it. The only reasons to use it are that it's pretty much installed by default, and for some reason nobody has written a better version. Kinda weird really. I might vibe code one.
If you don't believe me, look at how recursive Make works, or how the job server works, or how to support paths containing spaces (you can't), or
.PHONY, or how the default rule is chosen, or ...makehas a huge amount of history, which is pretty much its selling point. We decided recently to introduce it into a project for command aliases, simply because it's available everywhere.justwould've been the objectively better tool for what we want to use it for. But slapping.PHONYonto everything is less big of a deal than telling all devs to install yet another tool before they can get started.Off the top of my head there's Just, Ninja and redo
Ninja isn't designed for hand written rules - it's more of a backend tool.
Redo is barely anything at all. It sounds kind of elegant but I've tried it - you basically end up assembling Make yourself from dozens of loose files.
Just isn't really a build system at all - it's a "command runner" like
npm run. I'm not sure it can even do dependency tracking like Make can it? In any case in my view it's worse because they've made it super complicated and kitchen sinky.For small stuff ninja is fine and the language is tiny and simple, no mad escaping. It gets completely out the way and you can do a lot before you have to reach for anything else.
Don’t forget Task! It’s yaml based and written in go. I like it. It works well. It has a few rough edges. Unfortunately, I haven’t given Just a chance yet to compare
I haven’t used it yet, but isn’t just a "better" version?
So there are multiple use cases here: one is a script runner, and the other is a directed act mix graph runner with timestamp based pruning.
Make is good for builds because it ignores unmodified data, and just is great as a script runner because it’s way more ergonomic than make to write.
I think they both have a good place, but for most languages other than C you need a script rune and the compiler does all the file selection and pruning.