4 ms·
I knew Make was terrible when I was first introduced to it. This is why I think everyone should learn programming first and linux second - since many linux too
by wrong_variable 10y ago
I knew Make was terrible when I was first introduced to it.
This is why I think everyone should learn programming first and linux second - since many linux tools are terrible.
As expressed in the SICP book - the programming language should allow you to build abstractions. Make doesn't at all allow that.
- dietrichepp 10y agoI think you were misinformed about the purpose of Make. It should not be used as a programming language. You can write a short makefile by hand, reasonably, which compiles a few source files, but anything larger should probably be automatically generated by CMake or your own scripts or whatever. Abstractions are perfectly possible, you just do it in your own script (Python or whatever) and this way you don't have to learn a new language. Ninja is a better alternative to Make, and it is even less expressive (which is one of the reasons why it is better, IMO). Or in other words, we build abstractions in Make by composing it with other tools, rather than creating a huge monolithic Makefile syntax which can do anything you want.
- tome 10y agoIn which case why even use Make at all? CMake could generate anything.
- dietrichepp 10y agoCMake can't generate anything, it only generates a few different types of files. Make is the most well-tested output, and there is only one alternative generator for CMake for the Linux command line anyway (Ninja, which is even less expressive than Make). It's like saying that "Why use assembly at all? GCC could generate anything." Well, yes. But you're on an x86 machine and there's an assembler right there for GCC to use, and GCC has been using that assembler for decades.
- wrong_variable 10y agoAll of these things sound complicated. What is CMake now ? Manipulating files is trivial in any programming language expect maybe in something like C,C++,Java,etc. Python/js/go make it really easy to deal with complex build systems or even just 1 liners. So I have no idea why make has any advantage over those - only use-case is if you are writing C where its non-trival to do file-handling. I moved to npm scripts once I asked the question "how do i make a multi-process build script in make ?" and all the neck-beards in uni had no answer - so I just write small scripts which grow and shrink based on my needs.
- pmoriarty 10y ago"I moved to npm scripts once I asked the question 'how do i make a multi-process build script in make ?' and all the neck-beards in uni had no answer" make --jobs=2
- dietrichepp 10y agoMake is really fast, and it's good at doing parallel builds (you just have to specify -j). You could try making something better in Python, but it would take a long time to write and Make is already here. You apparently had the opposite experience from me. I hate NPM build systems like Grunt and Gulp because they're hard to debug. Make is easy—keep the files around and tweak the command line until it works. No idea how you missed the -j option.
- veganman 10y agoWhy are you even posting if you have zero knowledge of the topic?
- fpoling 10y agoNice summary! It is indeed often missed but rathar important point that make syntax is generator-friendly. It allows to easily script make files or even glue them together from several generators. This ability to write and compose is a rare feature today. Json is pretty opposite to it and even Yaml is rather bad at it as to compose pieces one have to parse them first.
- cm3 10y agoThe problem with generated Makefiles is that you start to debug the generation step, if possible, if you want to tweak things, whereas a Makefile written by a human is usually easy to edit. Alternatively the generated Makefile could use overrides from an optional .mk file to be sourced, but that's not what I've seen with automake or cmake.
- marssaxman 10y agoAfter loathing make for decades and doing my best never to waste any time thinking about it, I spent a week digging in hard and learning it in detail, as though it were a programming language I actually wanted to use. It turned out to be just as terrible as I always thought it was, and I really don't want to use it - but I learned how to make it do the straightforward thing I have always wanted it to do, which I have often fumed and sputtered and groused at it for not doing, and I wrapped that knowledge up in a set of recipes which I now copy into every project I work on. This lets me take advantage of make's ubiquity without having to remember and worry about all of its odd awful corners. Here are the recipes, most recent version: https://github.com/marssaxman/ozette/blob/master/srctree.mk https://github.com/marssaxman/ozette/blob/master/srctree.mk And this is an example of a makefile using those recipes: https://github.com/marssaxman/ozette/blob/master/Makefile https://github.com/marssaxman/ozette/blob/master/Makefile