Hacker News new | ask | show | jobs
by akerl_ 2386 days ago
I think there’s a distinction to be drawn here between a couple use cases for Makefiles (specifically for building software):

* Makefiles can act as shortcuts for common existing functionality of the build toolchain

* Makefiles can add new functionality that is not part of the build toolchain

* Makefiles can add new functionality that replicates existing functionality in the build toolchain

An example of the first case is one of the first examples in the article: using `make build` to run `go build`. The second includes things like the later example for `make docker-push`. The third includes things like makefiles that generate intermediate files or other things that `go generate` could do.

Only the 3rd thing can really meaningfully harm productivity, but in my experience it’s the least common usage of `make`. A Makefiles that wraps `go generate && go build` into `make build` seems fully outside the scope of the portability concern, since a user without Make could just run the same commands themselves. Likewise, a Makefiles that adds `make release` which uploads the build artifact to GitHub Releases or similar isn’t replacing something the go toolchain could do, so it’s also not affecting portability. The user without Make couldn’t have used docker-push anyways, since the go compiler doesn’t support pushing release assets.

1 comments

I use make for the first case a lot. If there was a tool for running bash functions from a predefined file just as easy and ubiquitous as make, I would switch in a heartbeat.
Put "$@" at the bottom of the file. Then type ./filename function.

You can extend that to a fancier function dispatcher, argument checker, etc, if you want.

Well technically simple to do, that misses the point.

That is neither ubiquitous, nor (as a result), trivial for a newcomer to understand.

If I clone a repo and see a makefile, I know what to do.

If I clone a repo and see './hack.sh' or './runme' or './do' or whatever you chose to call it, I have no clue whether I should invoke it or not.

There are few alternatives to make that have the same level of mindshare, and thus the same ease of use for a given newcomer to grok what to do.

Most alternatives are language specific (e.g. "rake" in rails did a good job of building programmer expectations that you use 'rake ...' to do various common tasks).

If you name it "configure" then most people will run it; you can put the instructions there.