
Accidentally Turing-Complete - sebastialonso
http://beza1e1.tuxen.de/articles/accidentally_turing_complete.html
======
kbumsik
Also x86 mov instruction is Turing complete! [1]

There is a guy who run Doom with only mov instructions, but it is of course
incredibly slow, one frame every 7 hours :) [2]

[1]:
[https://news.ycombinator.com/item?id=9751312](https://news.ycombinator.com/item?id=9751312)

[2]:
[https://news.ycombinator.com/item?id=16218872](https://news.ycombinator.com/item?id=16218872)

~~~
xxs
I wonder how that one was missed as it's a famous example.

------
FartyMcFarter
On Magic The Gathering being Turing-complete, this is an interesting quote:

> Our result is also highly unusual in that all moves of both players are
> forced in the construction. This shows that even recognising who will win a
> game in which neither player has a non-trivial decision to make for the rest
> of the game is undecidable.

At first I thought this was pretty mind-blowing for a game, but actually this
is directly comparable with a Turing machine; each step is forced, mechanical
and very easy to derive, and yet, the overall behaviour is generally
undecidable.

~~~
lukifer
For anyone curious about the details of building a Turing machine in MtG,
Because Science did a thorough breakdown and demonstration, using actual
cards: [https://youtu.be/pdmODVYPDLA](https://youtu.be/pdmODVYPDLA)

------
janzer
While rather more dense, I find Gwern's article/list[1] a bit more extensive
(although missing a few from this list), while also having some interesting
commentary on security implications.

[1] [https://www.gwern.net/Turing-complete](https://www.gwern.net/Turing-
complete)

------
moreati
I'm still not sure if Python Pickles, _without_ the GLOBAL opcode to call into
Python, are Turing complete.

Python pickle files are a sequence of op-codes that run on the pickle VM. By
default the VM allows calls to arbitrary Python functions. I'm still puzzling
whether Python pickles without access to Python globals (e.g. using
[https://docs.python.org/3/library/pickle.html#restricting-
gl...](https://docs.python.org/3/library/pickle.html#restricting-gl...)) are
Turing complete. I don't think so, because the pickle VM has no branching or
looping, but it does have a stack and my understanding of automata theory is
not great.

My research/tinkering so far is [https://github.com/moreati/pickle-
fuzz](https://github.com/moreati/pickle-fuzz)

~~~
bugmen0t
Pickle is a stack machine
([https://en.wikipedia.org/wiki/Stack_machine](https://en.wikipedia.org/wiki/Stack_machine)).
It is Turing complete. See source code and documentation at
[https://github.com/python/cpython/blob/master/Lib/pickle.py#...](https://github.com/python/cpython/blob/master/Lib/pickle.py#L107and)
[https://github.com/python/cpython/blob/master/Lib/pickletool...](https://github.com/python/cpython/blob/master/Lib/pickletools.py#L38)

N.B: "Turing complete" really means a lot less than you seem to believe.

~~~
Dylan16807
A machine that has a stack and runs a series of instructions in sequence, no
looping or branching, is a pushdown automaton. That's significantly weaker
than Turing complete.

(A pushdown automaton can do branching if it wants, but the lack of looping /
going left is critical.)

------
anderskaseorg
This list is careful to mention that the PowerPoint machine requires the user
to perform an action for each step, but neglects to make the same disclaimer
for the HTML5 + CSS3 machine.

~~~
SQueeeeeL
I thought HTML5 was just a single button click.

~~~
Dylan16807
The version that's linked requires a button press for each colored box.

------
xurukefi
It's pretty hard to make something that is not turing-complete. I've always
wondered if it wouldn't be beneficial to have a turing-incomplete language
given that Rice's theorem then doesn't necessarily hold and thus very powerful
semantic analysis might be possible. But the language is then probably not
practical due to limited expressiveness.

~~~
fnrslvr
This is kinda part of the promise of regular expressions, context-free
grammars, relational algebra, map-reduce and other stream/pipeline-based
programming models, and maybe to some extent P-complete things like convex
optimizers and programming models based on horn clauses like datalog.

Each of these things aims to allow the user to specify a task in a restricted
model of computation. In turn, it tends to be possible for the engineer
writing the solver to build an engine capable of very radical transformations,
optimizations, and analyses, that generally can't be matched by compilers and
interpreters for Turing-complete programming languages.

~~~
miltondts
If I want to build a language with those optimizations, what resources could I
use?

------
Dylan16807
> HTML5 + CSS3

Nope. I'm going to argue this every time I see it. It only demonstrates basic
arithmetic. When an external actor has to come along and take each iteration's
output and manually do things with it, you don't have Turing completeness.

~~~
a1369209993
That is clearly a demonstration of Turing completeness, but it's a
demonstration of Turing completeness of HTML5 + CSS3 _\+ copying from output
back to input_ (the same as eg string rewriting systems) and that could stand
to be stated more clearly.

~~~
Dylan16807
Technically yes, but only when it's paired with the understanding that
arithmetic plus copying the output back to input is Turing complete. HTML5+CSS
is only supplying the arithmetic half of the equation.

------
k_sze
The game "Cities: Skylines" is also Turing-complete:
[https://medium.com/@balidani/cities-skylines-is-turing-
compl...](https://medium.com/@balidani/cities-skylines-is-turing-
complete-e5ccf75d1c3a)

~~~
Medox
Factorio too. Raycasting engine:
[https://www.youtube.com/watch?v=7lVAFcDX4eM](https://www.youtube.com/watch?v=7lVAFcDX4eM)

~~~
PythagoRascal
And "Baba Is You":
[https://twitter.com/mattar0d/status/1109987662608384000](https://twitter.com/mattar0d/status/1109987662608384000)

------
waynecochran
Turing Complete is not a very high bar. Add a second stack to a pushdown
automata and its Turing Complete. Add two counters to a NFA and it’s Turing
Complete. I am not sure if folks know what this means.

~~~
codeflo
Yes. Judging from the HN discussion of a very similar list a week ago, a loud
minority confuses “not Turing complete” with “sandboxed”. Hence lots of
discussions about security that seem to miss the point.

------
krick
Somebody should make awesome-turing-complete project on github, so we can
merge everything from the comments here into a neat list...

~~~
abetusk
Done [1]

[1] [https://github.com/abetusk/Awesome-Turing-Machine-
Equivalenc...](https://github.com/abetusk/Awesome-Turing-Machine-Equivalence)

------
NwtnsMthd
Turns out Pokemon Yellow is also Turing complete!

This fantastic hack escapes the game, loads a couple bootstrapping sequences
and then proceeds to turn Pokemon into a MIDI player.

[http://aurellem.org/vba-clojure/html/total-
control.html](http://aurellem.org/vba-clojure/html/total-control.html)

~~~
Dylan16807
* using an enormous glitch.

It's really cool, but it's notably different from using actual ingame
mechanics to compute.

And there are much more fun versions of pokemon yellow total control than the
link you and the article have.
[https://www.youtube.com/watch?v=zZCqoHHtovQ](https://www.youtube.com/watch?v=zZCqoHHtovQ)

------
asplake
How concerned should we be that BGP is in there?

------
favorited
The C++ templates example is kind of a meme, and Bjarne has pushed back on the
idea that it was "accidental."

Sure, they didn't set out saying "we want to design a Turing-complete generics
system" (because what kind of problem statement is that?), but templates were
explicitly designed to be as general-purpose as possible. Turing-completeness
was the result of that design goal:

"...I had aimed for generalty (and gotten Turing completeness modulo
translation limits). I opposed restrictions to C++ immediately when Erwin
Unruh presented what is widely believed to be the first template metaprogram
to the ISO Standards committee's evolution working group."

[http://www.stroustrup.com/bs_faq.html#understand](http://www.stroustrup.com/bs_faq.html#understand)

------
Hitton
> _In a very similar fashion to C++, the type system of TypeScript can be used
> to implement a prime check._

PCRE can do that too (for numbers in unary).
[https://www.masteringperl.org/2013/06/how-abigails-prime-
num...](https://www.masteringperl.org/2013/06/how-abigails-prime-number-
checker-works/)

------
malkia
But most importantly - should your config language be turing complete, or not
- or do we care or not?

~~~
AgentME
If a config file isn't deterministic (because it's executable _and_ can read
info from its environment), then it can be harder for tools to introspect on
the full config (imagine an IDE showing your project's settings or a tool that
validates it; the tool would be blind to what your config specifies in
environments the tool doesn't test with) or know when it's safe to cache the
config's result (because the tool doesn't necessarily know whether the
environment may have changed in a way the config cares about). (Extreme
example: if you had a software library that declared its list of dependencies
in an executable config file, and that config file could arbitrarily read the
environment, maybe toggling certain dependencies depending on your platform
and whether you had certain pre-requisites on your system, then a package
repository that the library is published on can't show a canonical list of the
library's dependencies. When a user wants to install the library and its
dependencies, the package repository server can't respond with library and its
dependencies together, because the library's dependencies for you could only
be found out by executing its executable dependency config on your computer
specifically, so the server would need to send you the library, your computer
would need run the dependency config, and then go back and ask the server for
the dependencies, and then repeat for their depedencies, etc.)

Also, executable config files (deterministic or not) aren't so easy or pretty
to programmatically modify. If the config file can define arbitrary functions
and use them to compute the config, then if you want to tweak the config with
a tool like an IDE or package manager, then it will need to try to recognize a
pattern in the config file, or add a chunk of code at the bottom that just
mutates the config file after your handwritten code.

------
numpad0
That Pokémon is an arbitrary code execution, not “accidentally turning
complete”

~~~
FartyMcFarter
But if a system allows code execution on its host CPU, and the host CPU is
Turing complete, this means the system itself is Turing complete too by
extension.

------
ViViDboarder
Oh hey, the Vim example is my project. Super fun to build.

------
arunc
Reminded me of the fact that D templates are not Turning Complete.

~~~
ben-schaaf
IIRC D templates are more powerful than C++ templates, and certainly turning
complete. CTFE is also turning complete.

