3 ms·
I use Makefiles to build Go applications for two reasons: it is available on the systems we develop on, and it provides a real alternative to writing bash scrip
by bborud 2y ago
I use Makefiles to build Go applications for two reasons: it is available on the systems we develop on, and it provides a real alternative to writing bash scripts.
Build scripts are bad. They tend to lead to complexity over time. It is very easy to just add some ad-hoc magic to solve a problem than to sit down and think about how one should structure things better. This makes it harder for people unfamiliar with the codebase to understand what is going on.
Then you need to choose a language. Bash? Well, not a lot of people know Bash all that well. And it isn't a very nice language to express the kinds of things you need to deal with to solve build problems. People don't bother learning Bash because Bash isn't a very useful language.
Python? What version? What libraries? Now you need to choose what tooling to use for maintaining your tooling. The embedded world uses lots of Python. The short version: it only makes things worse. People waste time having to learn how to maintain the tooling. If they don't, they will struggle.
Makefiles were made for building C. They are tailored to how to C toolchain works. When you make "proper" use of Makefiles this can provide you with a lot of help. If you program C. If you are programming in other languages: not so much.
The good thing about using Makefiles with as little magic as possible is that it forces people to keep things simple. It is okay that you don't make use of 99% of its features. Not everything has to be a demonstration of your mad <tool> skillz.
That being said: it would be nice to have a more approachable alternative to Make that can be used across languages. Something that promotoes declarative builds rather than allow scripting. Because if you allow people to write code to build things, you are not going to be able to understand most people's builds without setting aside time to study them.
- Arch-TK 2y agoYou seem to be describing the use of makefiles for the purpose they're intended for: Describing a DAG where each node is a file and each edge is a build step. This is not a misuse of Make and not what I'm complaining about. That being said, you're under the impression that you're somehow not writing posix shell/bash when writing a makefile. You still are.
- bborud 2y agoSure, but we're often making sparing use of what make has to offer, like the pattern rules. I think that's okay, but it is also a reminder that perhaps there is room for a similar tool that can support patterns and built-in mechanisms that are more useful to today's languages. Rust and Go in particular. I think there is a huge difference between implementing logic in bash and invoking programs using shell syntax. I am aware of the fact that a lot of people used to put shell script beyond simple invocations in Makefiles, but I see that as a degenerate case. You shouldn't do that.
- Arch-TK 2y ago> I am aware of the fact that a lot of people used to put shell script beyond simple invocations in Makefiles, but I see that as a degenerate case. You shouldn't do that. Okay, so I am not sure why you seemed to object to my initial comment specifically talking about this kind of use of Make.