So, I was reading about Bitcoin Script on their official documentation and found this line: "Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops." I tried to reason hard but couldn't understand why would someone make a language "purposefully non Turing-complete". What is the reason for this? What happens if a language become Turing Complete? And extending further, whether "with no loops" has anything to do with the script being non-Turing Complete?
Asked
Active
Viewed 329 times
0
-
1Downvoter, please let me know the reason for down voting. – Anoop Dixith Feb 03 '15 at 00:04
-
You might have been downvoted because your question might be too broad for Stack Overflow, or primarily opinion-based, which would make it off-topic according to the official guidelines. The best questions on Stack Overflow are ones that ask a single question and have one or a small handful of objectively correct answers. – Maximillian Laumeister Aug 23 '15 at 04:41
2 Answers
5
possible reasons:
- security: if there is no loops program will always terminate. user can't hang up the interpreter. if, in addition there is a limit on size of the script you can have pretty restrictive time constraints. another example of a language without loops is google queries. if google allowed loops in , users would be able to kill their servers
- simplicity: no loops make language much easier to read and write by non-programmers
- no need: if there is no business need for it then why bother?

piotrek
- 13,982
- 13
- 79
- 165
-
I wonder if it's still possible to overflow the stack of this script's interpreter ;-) – kostix Feb 03 '15 at 17:42
2
The main reason is because Bitcoin scripts are executed by all miners when processing/validating transactions, and we don't want them to get stuck in an infinite loop. Another reason is that according to this message from Mike Hearn, Bitcoin script was an afterthought of Satoshi to try to incorporate a few types of transactions he had had in mind. This might explain the fact that it is not so well designed and and has little expressiveness.
Ethereum has a different approach by allowing arbitrary loops but making the user pay for execution steps.

user3078439
- 305
- 1
- 10