Hacker News new | ask | show | jobs
by pydry 2167 days ago
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.
2 comments

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.