←back to thread

Be Aware of the Makefile Effect

(blog.yossarian.net)
431 points thunderbong | 4 comments | | HN request time: 0.483s | source
Show context
mianos ◴[] No.42664066[source]
I have an alternate theory: about 10% of developers can actually start something from scratch because they truly understand how things work (not that they always do it, but they could if needed). Another 40% can get the daily job done by copying and pasting code from local sources, Stack Overflow, GitHub, or an LLM—while kinda knowing what’s going on. That leaves 50% who don’t really know much beyond a few LeetCode puzzles and have no real grasp of what they’re copying and pasting.

Given that distribution, I’d guess that well over 50% of Makefiles are just random chunks of copied and pasted code that kinda work. If they’re lifted from something that already works, job done—next ticket.

I’m not blaming the tools themselves. Makefiles are well-known and not too verbose for smaller projects. They can be a bad choice for a 10,000-file monster—though I’ve seen some cleanly written Makefiles even for huge projects. Personally, it wouldn’t be my first choice. That said, I like Makefiles and have been using them on and off for at least 30 years.

replies(7): >>42664103 #>>42664461 #>>42664526 #>>42664536 #>>42664757 #>>42672850 #>>42676540 #
Loic ◴[] No.42664526[source]
I like Makefiles, but just for me. Each time I create a new personal project, I add a Makefile at the root, even if the only target is the most basic of the corresponding language. This is because I can't remember all the variations of all the languages and frameworks build "sequences". But "$ make" is easy.
replies(2): >>42664751 #>>42664822 #
choeger ◴[] No.42664751[source]
You're probably using the wrong tool and should consider a simple plain shell script (or a handful of them) for your tasks. test.sh, build.sh, etc.
replies(2): >>42666987 #>>42667376 #
nrclark ◴[] No.42667376[source]
(not the parent)

Make is - at its core - a tool for expressing and running short shell-scripts ("recipes", in Make parlance) with optional dependency relationships between each other.

Why would I want to spread out my build logic across a bunch of shell scripts that I have to stitch together, when Make is a nicely integrated solution to this exact problem?

replies(1): >>42668877 #
1. dwaltrip ◴[] No.42668877[source]
Any modern attempts to do this better than make? I often write small “infra” bash scripts in my projects, maybe I could use a tool like that.
replies(3): >>42669142 #>>42671292 #>>42675659 #
2. TheTaytay ◴[] No.42669142[source]
I haven’t used them yet, but I keep seeing people touting alternatives, and in particular “just”: https://github.com/casey/just

This is primarily aimed at a “task runner” replacement rather than a “compilation with automatic file timestamp comparison replacement”

Others I stumbled across: Taskfile Mage XcFile

None of them have tempted me enough to move away from a set of bash scripts or scripts written in the language of my repo (yet).

3. ori_b ◴[] No.42671292[source]
That depends. Why do think make does this poorly?
4. nrclark ◴[] No.42675659[source]
`Just` is also popular in this space, but tbh I think Make is a better choice.

Make is included in most Linux distros, including the ones available for WSL. It's also included with Apple's developer tools. It's been used for decades by millions of people, and is very mature.

If you use it in a simple way, Make is almost identical to `Just`. And when/if you want Make's powerful features, they're there and ready for you. Make's documentation is also exceptional.

I've used a bunch of these kinds of tools over the years, and I've never found one that I like more than Make.