6 ms·
"The author could have replaced it with a shell script that read $1 and matched on it to determine what to do." Or just with a simple command runner like just.
by weinzierl 2y ago
"The author could have replaced it with a shell script that read $1 and matched on it to determine what to do."
Or just with a simple command runner like just.
https://just.systems/ https://just.systems/
- a5c11 2y agoOr just with a simple command which is guaranteed to be on most Linux systems already - make. Maybe his Makefiles aren't complex, nor they seem to follow all the best practices invented by code gurus in sandals, but it works and, what's important, it works for him.
- hulitu 2y ago> but it works That it what a lot of SW developers forget: your code might be the best in the world, but , if someone is not able to build it, it is useless.
- wruza 2y agoI remember countless times me and forum fellas debugging makefiles written under developers’ assumptions about systems. That is also what lots of developers forget or simply aren’t aware of. Make isn’t a silver bullet for builds. It isn’t even a bullet. Most software gets built from scratch and make’s deps graph makes little to zero sense in this mode. Make is a quirky poor dev tool footgun, jack of all trades master of none.
- kaba0 2y agoMake leaves the actual hard problem behind — setting up the environment correctly. A README file is much more useful.
- weinzierl 2y agoThere was a time when people would have said the same about make. The shell is the simple command that is guaranteed to be on all Unix systems from the get go. Make is the new kid on the block. If you just want to run commands in the order written down, don't need the topological sorting feature of make and value ubiquity then a shell script is the answer. If you are not stuck in the past and you truly live by the UNIX philosophy of doing one thing and doing it well, a command runner is the answer. The command runner avoids the ton of foot guns both shell scripts (no matter which flavor) and make files have. just also brings a couple of features out of the box that would be very tedious and error prone that replicate in make and shell scripts.
- darby_nine 2y agoRight but writing dependency management (of targets, not package management) in shell seems like a nightmare compared to just leveraging make. Why complicate things? It's dead simple to debug, the interface is dead simple, what's the downside?
- tcfhgj 2y agoIn my PS script solution, I just added a clean option+command. I rewrote my makefile in PS and don't miss anything from make and have no regrets, as it is simpler now.
- boomlinde 2y agoRight, but the original point which started the thread is that "The author is not even using the mtime-based dependency tracking", in which case a plain shell script is very much a viable alternative to make. I don't particularly mind this use of make, but as an article on make it fails to exemplify what I think is its main purpose.
- darby_nine 2y agoI don't think that really matters. Sometimes even basic shell scripts are better modeled with a makefile.
- movedx 2y agoI believe you to be correct. I think it's important that one uses the right tool for the job, regardless of whether or not it's widely adopted or supported.
- kristiandupont 2y ago>Make is the new kid on the block. Make is from 1976. I don't think you can legitimately refer to it as that.
- Ygg2 2y ago
- ReleaseCandidat 2y ago> it works and, what's important, it works for him. Until it doesn't. And then you really have to learn about PHONY targets, why and when there must be a tab and not spaces - good luck with an editor that doesn't treat Makefiles special and is configured to convert tabs to spaces.
- dented42 2y agoBut those are things that he’ll learn about as he keeps using make. And why does it matter that some editors don’t know about makefiles? The one he is using handles them just fine so what’s the problem?
- ReleaseCandidat 2y ago> And why does it matter that some editors don’t know about makefiles? Because it isn't fun checking if the whitespace at the beginning of the line is a tab or spaces. And as said, you must know when to use tabs and/or spaces in rules. For doing such a simple thing as calling some commands, Make has way too many subtle footguns which _will_ bite somebody, someday. The problem (that's not a problém at all, that's a reason to celebrate!) is that most JS devs and users aren't used to Make, compared to e.g. C programmers. To rephrase: as someone writing C, you have to use something like a Makefile, as anything else (like scripts) gets unreadable and -usable quite fast. But if you can get away with a less complex solution, you should really use that instead of Make.
- instig007 2y ago> Because it isn't fun checking if the whitespace at the beginning of the line is a tab or spaces. And as said, you must know when to use tabs and/or spaces in rules. that's why https://editorconfig.org/ https://editorconfig.org/ exists, so that neither you nor your teammates have to think about these things
- ReleaseCandidat 2y ago> neither you nor your teammates have to think about these things You're better off using a Makefile linter. But you must know about the problem before being able to solve it. And error messages like Makefile:2: *** missing separator. Stop. aren't the most helpful.
- unscaled 2y agoOr just use a simple command which ALL Unix system have: sh. If you're using make a glorified task runner, why don't you just create a scripts/ directory with shell scripts to do whatever you want. This is simpler, cleaner and works everywhere. Make doesn't really add anything. I get the feeling that using make this way is an aesthetic preference that has somehow developed with time into a "this is the one true Unix way" cargo cult.
- deepsun 2y agobin/ directory.
- darby_nine 2y agoWhy not just use make? I am constantly confused by people reinventing the wheel with new syntax and little benefit
- eloisant 2y agoBecause make is a huge PITA
- maccard 2y agoWhen step one of using a tool is to disable the tools primary benefit (everything is phone) you’re reaching for the wrong tool. Like it or lump it, make deploy is much neater than docker build -t foo . && docker tag foo $item && docker login && docker push && helm apply I wish there was a flag for make which set it to be a command runner by default for the current makefile.
- darby_nine 2y agoMake's clear benefit is laying out a process as a series of dependencies.
- deepsun 2y agoWhy not just use shell scripts? Why additional complexity?
- darby_nine 2y agoShell scripts are additional complexity? I'm not sure what you mean. Adding structure reduces complexity.
- deepsun 2y agoNo I mean Makefiles, how author uses them, are additional complexity over shell scripts. The whole difference of Makefiles, their original idea was to not re-compile a target _file_ if it's already there. So if you need .PHONY -- you're using Makefiles wrongly.
- 112233 2y agoPlease help me understand why this thing exists. Like, no snark, I like using the proper tool for a job -- when would I look at the project and think "this is something that is better done with 'just' tool". Instead of readme.txt and a folder with scripts
- kaba0 2y agoI can count on one hand the number of times a simple script or make worked out of the box. Sure, part of the reason is dependencies, but then I might as well use a build tool that is actually doing what a build tool should. Makefiles/bash scripts are hacks, and I don’t get this strange Stockholm syndrome UNIX-people have for them.
- sgarland 2y agoIt’s gotten some syntactic sugar recently that’s made it pretty nice. Specifically, I’m thinking of its OS-specific sections: you can do something like [macos] # do a thing And without any other checks, that section will only ever run on Mac. Yes, of course you can replicate this in Make, but it isn’t nearly that easy.
- safety1st 2y agoThe strengths of make, in this context where it's been coaxed into serving as a task runner for small projects, are: 1) It's already installed practically everywhere 2) It reduces your cognitive load for all sorts of tasks down to just remembering one verb which you can reuse across multiple projects, even if the implementation ends up differing a bit 3) In conjunction with the similarly ubiquitous SSH and git, you have everything you need to apply the basic principles of DevOps automation and IaC There's something special about waking up one day with an idea, and being able to create a fresh git repository where the first commit is the Makefile you've had in your back pocket for years that scripts everything from environment setup to deployment to test automation to code reviews. There's zero effort beyond just copying your single file "cookbook" into that new repo.
- yunohn 2y ago> It's already installed practically everywhere This always comes up, and is a sad chicken/egg problem. We can all somehow agree that Make mostly sucks, but OS maintainers aren’t interested in providing a default alternative, due to choice overload or something.
- badgersnake 2y agoThis entire article and discussion is about why people like make.
- yunohn 2y agoNo, a significant amount of the comments here are about how Make sucks.
- hulitu 2y agoCMake runs make, ninja runs make.
- IshKebab 2y ago> It's already installed practically everywhere Well, except Windows. But nobody uses that right?
- nsonha 2y agowhy do you need a "command runner"? Have you heard of bash functions? Or... make? The thing is too simple to justify installing another tool, however nifty it is.
- flooow 2y ago`just` is great and I use it all the time. * All commands in one place, view them all with `just --list` * Stupid-simple format * Small standalone binary * Configurable (with arguments, environment variables etc) but not _too_ configurable When I see a git repo with a Makefile, I'm filled with dread. When I see a repo with a Justfile, I get warm fuzzies. Some people say it just doesn't do enough to justify existing. These people are just wrong.
- aerzen 2y agoTo me, just is make without features I don't need. There is not a lot of benefit for me, but there is a lot of benefit for other people who need to learn the repo and have no knowledge of either make or just. Another benefit is that justfile just cannot get too complex and tangled. Simplicity at its finest.