Live data from Hacker News

Makefiles for web work

rosszurowski.com

31–40 of 58 posts

Re: Makefiles for web work

#31

It's interesting, but I can't help but think that by the time you're adding `.PHONY` after most rules, you're not using the right tool for the job. (I generally find a small set of shell scripts work, or just three or four rules in the package.json file I can access with `npm run`).

I think .PHONY is mostly fine, but as soon as you have any sort of runtime arguments or interactive stdin/stdout you are definitely using the wrong tool.

Re: Makefiles for web work

#32

Earlier quoted context omitted.

It's not an exaggeration when you inevitably end up chaining them. The overhead adds up very quickly and becomes noticeable. Also they take even longer to start in CI/CD containers.

true, but the moment you add containers to your mix you're functionally admitting that you don't care about startup times. Or possibly, you've been forced to do it by some service provider who doesn't give you a better option...

I mean you're not wrong in general, it's just that if the tool is written in C/C++, Zig, Rust, Golang, OCaml, D, V, and a few others, it still start in maximum 20ms even in containers.

Re: Makefiles for web work

#33

Earlier quoted context omitted.

I agree. It has its merits, but it's hard for me to get around my visceral reaction to the fact it just bombs on filenames with spaces in them.

You can escape spaces in makefiles.

Sure... but if you have spaces in filenames, and filenames in variables, what happens then?

Re: Makefiles for web work

#34
Totally agree with the author. As someone who jumps between multiple projects, in different languages-I have hard time remembering what build/test/script runner in used in particular project. Hell, even two JS/TS projects can use different tools (one could use npm with jest, the other yarn with webpack, etc).

I written[1] a blog on that as well. Glad to see there are more like minded people out there.

[1] https://www.yieldcode.blog/post/why-you-should-adpot-makefil...

Re: Makefiles for web work

#35

It's interesting, but I can't help but think that by the time you're adding `.PHONY` after most rules, you're not using the right tool for the job. (I generally find a small set of shell scripts work, or just three or four rules in the package.json file I can access with `npm run`).

I think the reason for the .PHONY is just so people don't have to ./

I generally reach for a shell script with "case" instead, though. Can always invoke make from the shell script.

Re: Makefiles for web work

#36
post #8

Make becomes a pretty terrible tool at a fairly low level of complexity. I would never choose it voluntarily to build things.

Yeah, think of how programming languages invent and reinvent stuff to handle the interaction with Make and native libraries, how we have generators of generators of Makefiles... Heck, even Docker's use case is mostly because of the living hell that is C stuff.

Re: Makefiles for web work

#37
post #26

I tried repeatedly to just stick with Makefiles but I kept having to add workaround and hack to do basic stuff. They got uglier and uglier. I checked out go task and cargo make, but eventually gave in to `just`. It has worked just fine and the files are infinitely more readable than the comparable ones w/ make.

What kind of workarounds and hacks? Make's task interface is essentially "anything you can do at the command line", generally with the same syntax (though you have to put extra parens around your variable names). It's true that more modern tools have features make doesn't (especially with regard to manipulating complicated dependency graphs) or attack parts of the problem that make doesn't (hermetic build environment…

I see `.PHONY` as a hack, `MAKEFLAGS += --no-builtin-rules` as a workaround, and many of the builtin functions as being difficult to use, read, and understand. A long string of nested replacements generating the sources for a task is a pain to read and maintain.

What I want out of task runners nowadays is to run tasks. If I can't make a task without writing '.PHONY' - there's a problem with the task runner.

Re: Makefiles for web work

#38

It's interesting, but I can't help but think that by the time you're adding `.PHONY` after most rules, you're not using the right tool for the job. (I generally find a small set of shell scripts work, or just three or four rules in the package.json file I can access with `npm run`).

https://c.tenor.com/2hLnLe93160AAAAd/family-guy-youre-a-big-...

Re: Makefiles for web work

#39
`make` is not a taskrunner, it is for tracking dependencies between files. a .PHONY target that isn't named "all", "clean", or "dist" is a code smell. there are many design decisions in `make` that are the opposite of what you want in a taskrunner:

* each line executes in an isolated environment

* can't pass options or arguments to a make target

* not portable to other operating systems

the author is already using node packages. purpose-built taskrunners are plentiful, and the resulting scripts will be written in the same language as the rest of the codebase instead of adding a second language.

hiding a tool behind a makefile is my pet peeve. a proper taskrunner makes common operations easy without kneecapping the flexibility of the underlying tools.

Re: Makefiles for web work

#40
post #26

Earlier quoted context omitted.

What kind of workarounds and hacks? Make's task interface is essentially "anything you can do at the command line", generally with the same syntax (though you have to put extra parens around your variable names). It's true that more modern tools have features make doesn't (especially with regard to manipulating complicated dependency graphs) or attack parts of the problem that make doesn't (hermetic build environment…

I see `.PHONY` as a hack, `MAKEFLAGS += --no-builtin-rules` as a workaround, and many of the builtin functions as being difficult to use, read, and understand. A long string of nested replacements generating the sources for a task is a pain to read and maintain. What I want out of task runners nowadays is to run tasks . If I can't make a task without writing '.PHONY' - there's a problem with the task runner.

Meh. OK. Though almost always, "run tasks" implies some level of state. Are you tasks truly all idempotent and parallelizable? If not, maybe they should produce output and be tracked by dependencies? If so, then you probably have bugs in your "task runners" that will show up in weird ways.

It's absolutely true that ".PHONY" looks like a hack; it was sort of meant to. In general you shouldn't be using it, except maybe as a facade layer where you can put an "API" (c.f. the "all" or "clean" targets) on top of things that are themselves proper dependencies.

I'm not going to hold up make as the ultimate expression of a dependency-based build system. But I will say that history has a LONG trail of products that tried to replace it with decidedly mixed results. Categorical statements like yours tend to trigger my "code smell" layer, most of the time attempts to replace make produce worse results.

Post reply on HN