69 points · by wurosh · 5y ago · 40 comments
This feels like when you set up a club for a hobby you enjoy, let's say it's beer pong, and you go on holiday for a month, you come back to find that your beer pong club is now full of people just chugging lots of beer and completely ignoring the game.
Please, make is a sophisticated tool with lots of good features. It is NOT a repository for "dev commands" whatever the hell that means. Make is a tool which takes targets, dependencies and recipes and turns them into a DAG which it then executes based on a set of criteria. If you want a glorified shell script which runs commands, why not just do a bash script with a switch in it? It's certainly going to behave a lot more like you expect. Why call it cake when it has almost nothing to do with make?
What it means is that it doesn't matter if I run `make test`, my coworker runs `make test` or the CI system runs `make test`, we all end up with the same result. Namely that the test suite will be run, after all stuff is done that is needed to setup the dev environment. Basically you codify all actions you as a developer would need, to setup, verify or use a project and all the dependencies between them. This makes your projects portable and when you have multiple projects (in different languages), getting it setup and running the test suite is the same for each one of them.
Why not use a bash script? That's how I started off but once a coworker introduced me to Make I never looked back. Bash scales really badly in terms of readability and maintainability.
I'm sorry to be the one to tell you this but neither you nor your coworker know what make is if all you think it is is a way to store subcommands.
If you want shell scripts write shell scripts. If you want them all to stem from one command (as subcommands), use a switch statement. These solutions will actually likely be far more reliable and portable (if you know what you're doing, I would imagine it's easier with portable shell than portable shell in make since even most of the programmers I know who use make for the purpose it was designed for don't seem to understand it very well).
Still, a Makefile with only targets, no prerequisites is less cruft than a Bash script with a switch statement. But eventually your (team) needs will grow and you start to introduce more logic and dependencies. This is where Make shines for me.
[0] https://gitlab.com/internet-cleanup-foundation/web-security-...
If you understand make, your makefile will behave as you expect it to. If you try to read a makefile as a shell script you'll constantly be surprised.
I know what make is and I know how to use it, thanks.
Because with bash scripts you'd be re-inventing the wheel when it comes to dependencies, among other things.
Make certainly might not be the right tool for having a bunch of "dev commands" that aren't targets/recipes, but bash isn't it either. There is plenty of task runners that allow you to have a single source of truth for dev commands.
In fact, nothing is stopping people from using make for some things and leaving the bulk of everything else to a separate shell script.
Give my Run tool a try:
Run: Easily manage and invoke small scripts and wrappers https://github.com/TekWizely/run
Here is another alternative:
I sometimes chime in on posts where OP makes a tool in the same domain as Run.
When I hit this article yesterday, the bash script convo hadn't started yet and I saw the OPs creation as not being in the same realm as Run, so didn't chime in.
But now that its been mentioned :)
Anyway I got a few extra subs from your call out, so thanks again for that!
(actually I just spent the last 30 mins reviewing 24 hours of HN posts to see where the call out might have come from, and finally found it :) -- Surprisingly google hasn't indexed this post yet so didn't show up in my saved search )
Pydoit is the sweet spot for most of my use cases:
- it scales up (graph of deps, file watcher, etc) but above all, it scales DOWN (simple stuff are dead simple)
- it promotes a declarative task definition
- it embraces the shell yet let you use python if you need to
- it gets out of your way and doesn't try to rule your project. It just runs what you want and disapear.
- the doc is nice
The biggest drawback is that you need to pip install it, which means non python devs will avoid it. I wish it was provided as an stand alone executable
which wholly abstracts "pip install this thing that has an entry_point without hating your life."
Still, make kinda sucks. I've yet to meet a build system that ticks these boxes: multi-language, simple, fast.
Even the fact it's using python to declare your tasks is not a problem: it's basically a function signature and a mapping, nothing you can't master in 5 minutes, and certainly simpler than make files DSL. Also easier to get right and debug.
The problem is the fact you need python to install it and run it, which non python dev will rightfully not care to do.
With that in mind, I toss my tool into the ring:
Run: Easily manage and invoke small scripts and wrappers - https://github.com/TekWizely/run