r/Python • • Nov 24 '16

The Case for Python 3

https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/
575 Upvotes

349 comments sorted by

View all comments

223

u/Workaphobia Nov 24 '16

I was willing to give the benefit of the doubt until the part where Shaw claims Python 3 is not Turing-complete. I can't understand how he could say something so demonstrably false.

76

u/[deleted] Nov 24 '16

Does he want a mathematical proof that it is?

Actually, that's not hard. Brain fuck is proven Turing complete (so is the game of life).

Write any of those in python, and that is a proof that python is at least as powerful as them, therefore python is Turing complete.

71

u/meltingdiamond Nov 24 '16

Writing a brainfuck interpreter has to be the worst way to prove turning completeness.

24

u/Han-ChewieSexyFanfic Nov 24 '16

If by worst you mean best, then yes.

20

u/talideon Nov 24 '16

Far from it. Brainfuck is quite a good way. It's equivalent to Corrado Böhm's P′′, but a bit more friendly: https://en.wikipedia.org/wiki/P′′

19

u/kewlness Nov 24 '16

That is the first time I have ever seen Brainfuck and "friendly" in the same sentence...

18

u/[deleted] Nov 24 '16

It's a really easy language to write an intepreter for.

14

u/kjmitch Nov 24 '16

It's called Brainfuck because it's seemingly impossible to read by humans, which is an important job for real programming languages. From the perspective of the computer/interpreter, it's much easier to understand (and therefore write an interpreter for) as it only has eight operations. It's practically just assembler code without all the semi-English names given to the commands for readability.

3

u/talideon Nov 24 '16

Compared to P′′, it's friendly!

Also, it's implementer-friendly: parsing and tokenisation are trivial, as is implementing the interpreter. I wrote a 260-byte-long one in ARM assembly language back in the '90s just for fun.

Coding anything in Brainfuck, well, that's another matter!

→ More replies (4)

31

u/MrJohz Nov 24 '16

It's actually a fairly common procedure. Not necessarily BF, but proof by implementation is a well-known technique for proving Turing-completeness.

7

u/wilerson Nov 24 '16

A friend of mine wrote a converter that converts Brainfuck to one line of Python code to prove Python one-liners are turing complete: http://www.ricbit.com/code/turing.py

Explanation (in Portuguese, sorry): http://blog.ricbit.com/2008/05/python-one-liners-so-turing-complete.html

6

u/kjmitch Nov 24 '16

It's actually probably one of the simpler ways to do so. Brainfuck's esoteric-ness comes from its being hard to read by human programmers, which is important in a programming language. But the structure of the language itself (eight commands gets you everywhere) is a testament to the fact that computers in this universe are made of complexity that can emerge entirely from simple rules.

→ More replies (2)

17

u/ismtrn Nov 24 '16

You would also have to prove that your implementation matches the brain fuck semantics which have been proven Turing complete, in order for it to constitute an actual mathematical proof. This well not be easy. I don't even think anybody has given Python formal semantics.

Luckily it does not matter, because you can write usable programs in Python which is the thing that actually matters. Actually it would be cooler if it turned out that Python was not Turing complete, because that would mean we could potentially solve the halting problem for Python programs (along with a bunch of other cool stuff) which would be really handy.

23

u/imbaczek Nov 24 '16

actually turing-completeness is so easy to accidentally achieve that whole type systems have to be specially designed to avoid making them turing-complete, e.g. C++ templates vs Hindley-Milner.

6

u/ismtrn Nov 24 '16

Yeah, intuitively python is obviously Turing complete because you can write algorithms in it. This is basically the Curch-Turing thesis, but it is not a formal proof.

→ More replies (2)

4

u/waxzup Nov 24 '16

I'm so confused. What on earth is "Turing complete"?

→ More replies (7)

6

u/evinrows Nov 24 '16

Hey, I wrote a turing machine emulator and a conway's game of life implementation in py3 when I was in college.

I knew these would come in handy some day!

5

u/flying-sheep Nov 24 '16

since this obviously exists, zed’s proven wrong.

29

u/choikwa Nov 24 '16

I see a rant of a salty person who can't use python2 with python3 vm. At this point they divulged too much to get any backward compatibility -- it's time to move on if you want latest PEPs

7

u/Watthertz Nov 24 '16

What is it about the Python 3 VM that would prevent someone from implementing a Python2 interpreter? Unless he's arguing that because Python 2 and 3 have different syntax then Python 3 isn't Turing Complete, which is clearly ridiculous.

5

u/Workaphobia Nov 24 '16

He's basically arguing that Turing complete languages must all have the same syntax and semantics. Nonsense.

12

u/IamWiddershins Nov 24 '16

He's completely lost his fucking marbles. I don't think he makes a single correct point the entire article. The man is either senile, maliciously lying, on drugs, or flatly stupid/insane.

6

u/[deleted] Nov 24 '16

I suggest the second as he wants to sell more books. Heck, in over 40 years in electrical and electronic engineering and computing I cannot recall such an abysmal article.

7

u/gandalfx Nov 24 '16

I've never heard much about this Zed guy but after reading that paragraph about Python3 not being Turing complete it appears quite obvious that he's either a very prominent troll or has no idea what Turing completeness even means.

it’s complete and utter nonsense, on a platform aimed at people who can’t yet recognize it as nonsense.

Eevee got the truth of it right there, nothing less.

8

u/doubleunplussed Nov 24 '16 edited Nov 25 '16

That bit is clearly facetious. He's saying that the devs claim it's impossible to run python 2 code from python 3. Now, the only way that could be literally true is if python 3 were not Turing complete. Therefore, the python devs are claiming python 3 is not Turing complete. This is Zed's way of calling them liars.

Of course the devs' real reason is that it's hard, not mathematically impossible. But if they were claiming it were literally impossible, Zed would have a point. It's not impossible, just hard, and the debate is really about whether it is hard enough or useful enough to have been attempted.

→ More replies (1)