Live data from Hacker News

Make for hipsters

mattandre.ws

41–50 of 200 posts

Re: Make for hipsters

#41

The single biggest piece of advice I can give for Make is to make sure your text editor uses real tabs in Makefiles. My personal preference for everything is spaces (mostly a habit learned from Python's PEP 8), but Make doesn't honour spaces for indentation - only tabs. Despite being an obvious usability hole, this has never been fixed. Exacerbating the issue is the poor error message given upon encountering a space-…

I mostly work in Python as well, but I always include an .editorconfig file in each project to automatically set things like

    [Makefile]
    indent_style = tab
http://editorconfig.org/

https://github.com/aaronbassett/EditorConfig/blob/master/.ed...

Re: Make for hipsters

#42
post #8

This introduction neglects to mention that Makefile rules are primarily rules to derive files (usually from other files). Make will not re-run a rule when the target (file) generated by the rule is already up to date. From this perspective, a well structured Makefile can be thought of as a pipeline/graph of functions, that derive values (files) from previously known values (files). Expressing a build process in this…

This sounds nice, except that the only kinds of dependencies are files (e.g. variables are excluded), and the dependencies should be mentioned explicitly, or things get ugly, especially when using non-standard compilers/tools.

Re: Make for hipsters

#43

Make is a great tool for automating simple things, but if you use a programming language you should probably use native automation tools for common tasks. If you have any non-trivial logic or want to enable code-reuse make doesn't seem like the right choice either.

I hate this. Every programming language that bolts on its own build environment. Make is language agnostic and that's a huge benefit, it means you have to learn about just one build tool and its peculiarities and that will allow you to build many different projects in different languages. All these languages with their half-baked build tools that won't accept that they may have to play nice with other languages and t…

Notice how in the article nothing is "built", all that happens is an npm install. It sounds like make is used to manage a project and perhaps do things like running unit tests, pushing code to stage/qa/prod, fetch data from remote hosts to test locally, running linters and code analysis tools, generating assets, and many more.

Is make the right tool for executing such tasks? Well, it's not bad for some I guess, and ok if this one project is all you have.

Re: Make for hipsters

#44
post #37
post #25

Earlier quoted context omitted.

(1) I imagine quite a lot of this site's visitors use different platforms/toolchains, and haven't encountered make. (2) Its a fun/joke title, the article is for "hipsters", the kind who know the latest fancy build tools but not make, I suppose. I wouldn't take it too seriously. (3) It's a disclaimer against people attacking him for errors, and also to warn people that he's not an expert. Again, this is written in a l…

If not a ruse, this is a dumb post that discredits itself and calls makefiles hacky, not noticing that they are used by many people for most native programming on most (unix type) platforms. I'm feeling cranky every day, but just today this post is at the top of hacker news, and that's frustrating.

The refusal of so many people in this industry to learn a pretty simple and incredibly fundamental tool frustrates me no end.

I guess this article could be worse: the number of times I see people reimplement poorly thought out clones of make and present them as the new thing that everyone should use is just absurd.

Re: Make for hipsters

#45

The single biggest piece of advice I can give for Make is to make sure your text editor uses real tabs in Makefiles. My personal preference for everything is spaces (mostly a habit learned from Python's PEP 8), but Make doesn't honour spaces for indentation - only tabs. Despite being an obvious usability hole, this has never been fixed. Exacerbating the issue is the poor error message given upon encountering a space-…

> Despite being an obvious usability hole, this has never been fixed.

You can now change the prefix for your recipes by setting the .RECIPEPREFIX special variable (https://www.gnu.org/software/make/manual/html_node/Special-V...).

That being said, with a properly configured editor I've actually found that TAB is an ideal character for the recipe prefix.

Re: Make for hipsters

#46
post #37
post #25

Earlier quoted context omitted.

(1) I imagine quite a lot of this site's visitors use different platforms/toolchains, and haven't encountered make. (2) Its a fun/joke title, the article is for "hipsters", the kind who know the latest fancy build tools but not make, I suppose. I wouldn't take it too seriously. (3) It's a disclaimer against people attacking him for errors, and also to warn people that he's not an expert. Again, this is written in a l…

If not a ruse, this is a dumb post that discredits itself and calls makefiles hacky, not noticing that they are used by many people for most native programming on most (unix type) platforms. I'm feeling cranky every day, but just today this post is at the top of hacker news, and that's frustrating.

[deleted]

Re: Make for hipsters

#47
post #35

One really neat thing about make: If you include other makefiles then before including them make checks if there are prerequisites of these files and rebuilds them as needed. One can use this to automatically generate header dependencies of translation units for C/C++ projects. Some of the relevant lines in one of my Makefiles: include ${DEPENDS} ${DEPDIR}/%.d: ${SRCDIR}/%.${SRCEXT} @mkdir -p ${shell dirname $@} ; \…

I think these days you're better off using -MMD to generate header dependencies at the same time as compiling, rather than doing it in a separate rule.

    %.o: %.c
            $(CC) $(CFLAGS) -MMD -c $

Re: Make for hipsters

#48
post #44
post #37

Earlier quoted context omitted.

If not a ruse, this is a dumb post that discredits itself and calls makefiles hacky, not noticing that they are used by many people for most native programming on most (unix type) platforms. I'm feeling cranky every day, but just today this post is at the top of hacker news, and that's frustrating.

The refusal of so many people in this industry to learn a pretty simple and incredibly fundamental tool frustrates me no end. I guess this article could be worse: the number of times I see people reimplement poorly thought out clones of make and present them as the new thing that everyone should use is just absurd.

You are frustrated about people not learning this tool, any yet when someone publishes an article encouraging people to learn that very tool, you damn it?

Re: Make for hipsters

#49
post #38

> You need to create a makefile to tell make what to do. Nope. You can say "make hello" and have make automatically use its default rules - which can be configured - to e.g. compile hello.c into a hello executable. I use this frequently.

I hate implicit rules. Also the %: %.c implicit rule is especially idiotic, it causes to check this rule for every single file, so if you have hello.h, then it will search for hello.h.c too.

Well, you either force people name their files correctly, or you make the computer do a little extra bookkeeping so that they don't have to. This is the silliest thing to hate about make that I've ever heard of.

Re: Make for hipsters

#50

Make is a great tool for automating simple things, but if you use a programming language you should probably use native automation tools for common tasks. If you have any non-trivial logic or want to enable code-reuse make doesn't seem like the right choice either.

I hate this. Every programming language that bolts on its own build environment. Make is language agnostic and that's a huge benefit, it means you have to learn about just one build tool and its peculiarities and that will allow you to build many different projects in different languages. All these languages with their half-baked build tools that won't accept that they may have to play nice with other languages and t…

> Of course it is great when you write a language to also throw in a build tool, but in the end if the build tool re-implements 30% or so of make in a broken way I don't see the point.

Well, other build tools sometimes also do a lot more than make ever did. (And in some areas, perhaps less.)

Example: Cabal/cabal-install (for Haskell) can automatically fetch all your project's dependencies and automatically compile them for you.

> Make does have its limitations, but most ordinary projects get nowhere close to reaching those.

I suppose it depends on what you mean by "ordinary", but IME this Makefiles by virtue of being purely file-based is useless for most of my projects. There are a many langauges (e.g. Java/Scala, Haskell) where it just doesn't fit for normal development. As an example: Tracking intra-file dependencies for proper recompilation is really difficult to for Scala code without reimplementing a huge chunk of a Scala compiler. (I'd venture to suggest that you'd be foolish to even try doing this in Make.)

Post reply on HN