4 ms·
I'm pleased to see this being espoused. One thing I always tell junior people is ""don't be tempted to think of make(1) as out-of-date [1], and to view package
by gjvc 5y ago
I'm pleased to see this being espoused. One thing I always tell junior people is ""don't be tempted to think of make(1) as out-of-date [1], and to view packages available via npm etc as better replacements, as many tasks fit the model of make(1), if not the title "a program for directing recompilation" "" I am often viewed with suspicion until I show them a (much more compact) replacement for their custom python/js program expressed as a makefile without any of the process management requiring debugging. :-)
An alternative approach for the "batches of files to process" situation is to generate the commands and feed them to GNU parallel for execution.
[1] no pun intended
- nicoburns 5y agoAgreed if you only have to support linux/unix, but the one good thing about the Node ecosystem is that they tend to work on windows too.
- gjvc 5y agonot the point, also "WSL"
- verelo 5y agoWhile i agree, I’ve spent literal days fighting with node modules in recent months. Sure make isn’t perfect either but it’s a lot less, confusing? Ie json isn’t a language for humans, but often you really need to read it to correct some issue or bad merge from another contributor.
- nicoburns 5y ago> Sure make isn’t perfect either but it’s a lot less, confusing? I think that's a matter of what you're used to. I don't use make all that often, so I find make files beyond a few lines quite a lot to get my head around, whereas I spend all day writing JavaScript so I can read/write JSON in my sleep.
- verelo 5y agoMaybe. I actually use node much more often, i don't even recall the last time i used a make file in production, i just find parsing json as a human to be rather painful.
- Steltek 5y agoMake has worked on Windows longer than Node.js has existed.
- nicoburns 5y agoMake works fine, it's the commands you call from make that don't tend to as compatible. For example, try running rm -rf on windows. It might work if you have GNU tools installed, but it certainly won't work out of the box. On the other hand, the node.js `rimraf` package will do the same thing with no cross-platform compatibility issues.
- Steltek 5y agoWhen using package.json, does npm intercept a script containing "rm -rf" and translate it to something different?
- geewee 5y agoNo, that's why there's a bunch of packages such as rimraf[0] that implements that sort of functionality in a cross-platform way that most people use in their scripts [0]: https://www.npmjs.com/package/rimraf https://www.npmjs.com/package/rimraf
- nicoburns 5y agoNo, but it does put binaries from any installed node packages in your PATH (locally when running scripts).
- jchw 5y agoThe history of Make on Windows would Make one think twice about relying on it. What shell do you get when running Make on Windows?
- throw0101a 5y agohttp://gnuwin32.sourceforge.net/packages/make.htm http://gnuwin32.sourceforge.net/packages/make.htm https://community.chocolatey.org/packages/make https://community.chocolatey.org/packages/make
- andrew_ 5y agoMight it not be a disservice to juniors to point them away from deeply understanding the platform they're working with?
- gjvc 5y agoShowing someone an alternative approach does not prevent someone "deeply understanding" their current method; it's not zero-sum.
- gjvc 5y agoMight it not be a disservice to juniors to point them away from deeply understanding the platform they're working with? I cannot overstate how annoyed I was by the patronising tone of this comment.
- jjice 5y agoBiggest pain of package.json to me is having to be crammed on one line. Slap in a conditional and now we have a messy thing to read, compared to its multiline counterpart.
- Wicher 5y agoSpeaking of debugging, I found this handy: print-%: ; @echo '$(subst ','\'',$*=$($*))' include Makefile Save somewhere, eg as ~/Makefile.debug, then when you want to know the evaluated value of some variable or task in some Makefile, you prefix it with print- — for example, LOCALES: make -f ~/Makefile.debug print-LOCALES It'll print the evaluated LOCALES of the Makefile in the directory you run this in.
- BeefWellington 5y agoThis is amazing. Thank you for the tip!
- gjvc 5y agoVery useful, will give it a shot. Thank you. :-)