Hacker News new | ask | show | jobs
by arauhala 2163 days ago
Preach to the choir! :)

Make does so many things correctly:

- it gives user total freedom to modify the built

- yet it has excellent defaults for most situations

- it is full blown programming language,

- yet it's syntax is extremely specialized for the purpose and familiar at the same time (it's bash)

- it's basic assumptions/structure are extremely simple (timestamps, dependencies)

- yet it's extremely powerful and can take into account most situations.

It's be extremely Unix-style tool with very simple building blocks that combine together in extremely powerful way. Its fast to learn and easy to master and as such, the best kind of design.

Sometimes making a build with it is a small programming project, yet after using all kinds of built tools, I end up just wishing that I could use make instead.

1 comments

bash is a pretty terrible programming language and it's terribleness increases geometrically with size. This is a large part of why people don't like make I think.
This is in fact another misconception:

> and familiar at the same time (it's bash)

Make is an orchestrator that defaults to sh (not bash, actually). But what I've seen in some really good ones is taking advantage of the "orchestrator" part rather than the "sh/bash" part: One-line recipes that simply call a short script in any other language, including python, that do the desired thing for that recipe. The Makefile is then just used for coordinating partial-running those scripts.

On top of that, you could in fact set SHELL/ONESHELL and then the recipes themselves are python inside the Makefile:

  SHELL := python
  .ONESHELL:

  testfile:
      import csv
      writer = csv.writer(open("$@", 'w'))
      writer.writerow(['one', 'two'])
      writer.writerow(['three', 'four'])
And:

  $ make testfile
  import csv
  writer = csv.writer(open("testfile", 'w'))
  writer.writerow(['one', 'two'])
  writer.writerow(['three', 'four'])
  $ cat testfile
  one,two
  three,four
Whoah! I didn't know about that feature. For most build tasks sh is probably best but this could be incredibly useful for some non build related things.

"Build tools are only for building software" is probably another falsehood to add, make can be a great tool anywhere you've got a dependency graph.

That's pretty neat, but I have never ever seen it used (not even in python projects). I'd be skeptical until I'd seen it used in anger.

It also would need to basically support virtualenvs and pip install to be really compelling, I think. Python without those is a pale imitation. That CSV module is known to be pretty bad, for instance (like many built in modules).

True, but it is familiar and quite useful for it's purpose (running scripts) :)

For build it mostly works fine. Doing anything else with it would be a total pain.