
Makefile Assignments are Turing-Complete - bidouilliste
http://nullprogram.com/blog/2016/04/30/
======
jgrahamc
Well, if you want to do computation inside GNU make there are tools like the
GNU make Standard Library: [http://gmsl.sf.net/](http://gmsl.sf.net/) and I
wrote quite a lot about GNU make stuff here ($$$):
[https://www.nostarch.com/gnumake](https://www.nostarch.com/gnumake) and here
(free): [http://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-
arti...](http://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-
articles.html)

------
Tunabrain
Doesn't Turing completeness require the ability to modify an arbitrary amount
of memory? (because the length of the tape on a Turing machine is unbounded).

However, if I understood correctly, the size of the Game of Life grid is fixed
in the Makefile and cannot be extended arbitrarily at runtime, making it not
Turing complete (cool nonetheless!).

Although, maybe a Makefile that generates a Makefile with an arbitrary number
of cells...?

~~~
dozzie
> Doesn't Turing completeness require the ability to modify an arbitrary
> amount of memory?

Why would it? Lambda calculus is nothing about modifying anything.

And GNU make (though with GNU extensions) is certainly Turing-complete:
[https://github.com/shinh/makelisp](https://github.com/shinh/makelisp)

~~~
Sharlin
In case of lambda calculus the equivalent condition is being able to evaluate
arbitrarily large expressions. This sort of a Makefile-based evaluator could
only do strings up to some hardcoded finite length.

------
ape4
Nice hack

------
lerax
OHHH! That is so sick. 174Kb of macros to implement a Conway's Game of Life

------
d33
I would say that this is a good argument against using such a complicated
spec. This kind of constructs should be explicit - if in a build system at
all. I hate Make because of all the crazy "build systems" that should have
been written in a more readable language, but ended up as a Make kludge.

~~~
Sharlin
The point is that, as mentioned in the article, the POSIX make spec is
positively barren! Indeed, this is another example of very _simple_
substitution systems turning out to be emergently Turing complete.

~~~
d33
So you'd say that it's a good thing? How is hidden complexity good?

~~~
Sharlin
It's not necessarily a good thing. It's definitely _interesting_ , though.
It's difficult to come up with systems that are simultaneously useful and
don't have emergent complexity - and it's not clear to me if it's worth the
effort to even try in the general case!

For what it's worth, in my opinion build systems should definitely be
intentionally, not accidentally, Turing complete.

