201 Opcodes, No Loops: Why Bitcoin Script Refuses to Be a Computer

Script has no loop, no jump and no recursion — termination is structural, not economic. That is a different answer to the problem Ethereum solves with gas. Taproot quietly replaced two of the constants with a weight budget.
⚠

No loop, no jump, no recursion

Five constants and no loop

Bitcoin Script is not a programming language in the sense you mean when you say programming language. There is no loop. There is no jump. There is no way to write a function and call it twice. Every script is a straight line of instructions from first byte to last, and that is not a limitation somebody forgot to lift — it is the property that makes the whole system safe to run on machines that do not trust each other.

I want to take this apart properly, because “Bitcoin can’t do smart contracts” is one of those sentences that is simultaneously true, misleading, and used to sell you something. The interesting part is not what Script lacks. It is why the lacks are structural rather than economic, and the fact that Taproot quietly replaced two of them with something else.

201 Opcodes, No Loops: Why Bitcoin Script Refuses to Be a Computer
Simiprof, CC0, via Wikimedia Commons

Taking the Constant File Apart

Open src/script/script.h in Bitcoin Core and the design philosophy is just sitting there as five integers:

520
MAX_SCRIPT_ELEMENT_SIZE

The largest single thing you may push onto the stack

201
MAX_OPS_PER_SCRIPT

Non-push opcodes allowed — pushes are not counted

10,000
MAX_SCRIPT_SIZE

Total script length in bytes

1,000
MAX_STACK_SIZE

Values the interpreter may hold at once

20
MAX_PUBKEYS_PER_MULTISIG

Keys in a single multisig check

Two of these are more interesting than they look.

201 counts only non-push operations. Pushing data is free as far as the counter is concerned. The limit is on work, not on size — which tells you what the limit is actually defending against.

520 bytes caps what any single stack element can be. That is why a P2SH redeem script, which gets pushed as data, has a practical ceiling, and why OP_SHA256 cannot hash a message longer than 520 bytes inside a script. It is not a cryptographic limit. It is a memory bound.

What Was Deliberately Left Out

The absences matter more than the numbers:

MAX_SCRIPT_ELEMENT_SIZE = 520 · MAX_OPS_PER_SCRIPT = 201 · MAX_SCRIPT_SIZE = 10000 · MAX_STACK_SIZE = 1000 · MAX_PUBKEYS_PER_MULTISIG = 20

  • No loops, no recursion, no jumps. No GOTO, no WHILE, no calling yourself. A script terminates because there is nothing in it that could continue.
  • No floating point. Integers only, and operands are limited to four bytes. Floating-point rounding differs between implementations, and “differs between implementations” is a consensus split waiting to happen.
  • No external data. No APIs, no price feeds, no oracle. A script cannot know what Bitcoin costs.
  • Almost no transaction introspection. A script cannot read output amounts, other inputs, or destination addresses. This is precisely what covenant proposals spend years arguing about.
  • No string manipulation. OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT were disabled in 2010 and stayed disabled.
  • No persistent state. A script executes once during validation and remembers nothing.

Point 1 is the load-bearing one. Termination here is a structural property, not a promise. You cannot write a script that runs forever, the same way you cannot write a sentence that never ends — the construct does not exist in the grammar.

The Comparison Everybody Gets Wrong

The usual move is to say Ethereum solved this with gas. It did not solve this. It solved a different problem.

Bitcoin ScriptEVM
TerminationStructural — no loop construct existsEconomic — gas runs out
Cost modelImplicit in size and opcode countExplicit per-instruction metering
Resource boundFixed constants, same for every scriptBudget chosen by the sender
Failure modeScript is invalidExecution reverts, gas is consumed
ExpressivenessSpending conditionsGeneral computation

Gas makes unbounded computation expensive, not bounded. A Turing-complete machine with gas can still be handed a program that burns an entire block’s worth of gas doing something useless; it just costs the sender money, and every node still has to execute it to find out. Script’s answer is to remove the branch instruction. Those are not two solutions to one problem. They are two different decisions about what the machine is for.

Gas is how you make a computer that charges rent. Removing the loop is how you make a thing that is not a computer at all. Both work. Only one of them can be audited by reading the grammar.
A protocol designer
not on the record, because nobody says this out loud
201 Opcodes, No Loops: Why Bitcoin Script Refuses to Be a Computer
D Coetzee, CC0, via Wikimedia Commons

What Taproot Changed, Quietly

Here is the part that is missing from nearly every explanation of Script’s limits: two of those constants no longer apply to Tapscript.

BIP-342 removed the 201-opcode limit and the 10,000-byte script size cap for Taproot script paths, and replaced them with a budget tied to witness weight: 50 weight units per signature operation passed, plus a 50-unit offset. The mechanism changed from counting instructions to weighing the witness.

Tapscript budget: 50 × (sigops passed) + 50 · → the bound moved from opcode count to witness weight

That is a real design shift, and it is worth being precise about what it does and does not mean. It does not make Script Turing-complete — there is still no loop. What it does is admit that “count opcodes” was a crude proxy for the thing actually being defended, which is validation cost. Counting was easy and safe; weighing is more honest about the resource. Bitcoin did not become programmable here. It became better at pricing the part it already allowed.

201 Opcodes, No Loops: Why Bitcoin Script Refuses to Be a Computer
Gaspar Schott, Public domain, via Wikimedia Commons

How to Read Any Future “Bitcoin Gets Smart Contracts” Story

Every few months a proposal shows up — covenants, OP_CAT, some new opcode — and the coverage says Bitcoin is finally getting smart contracts. Here is the method I use to read those, and it has not failed me yet:

  • Ask whether it introduces a jump. If yes, it is proposing to remove the structural termination guarantee, and the burden of proof is on the proposer. If no, it is adding vocabulary to a language that still cannot loop.
  • Ask whether the bound is a constant or a budget. Constants are auditable; budgets need a pricing model. Taproot moved two constants to a budget, and that trade was argued for years.
  • Ask whether it needs an oracle. If the exciting use case requires a price feed, note that Script still cannot read one, and the proposal is not the thing standing in the way.
  • Ask what it does to validation cost for a node that never uses the feature. This is the question that decides whether it ships.

Under that method, most of these stories are “Bitcoin is getting a slightly larger vocabulary for describing who may spend a coin.” Which is a good thing, and is not a computer.

The constants in that header file are not a list of missing features. They are a statement about what the machine is for: adjudicating who may spend a specific coin, under cryptographic and temporal conditions, in bounded time, identically on every machine on earth. It is much less than a computer, and that is exactly why it keeps working.

(The End)

Blockchain

Solana Swaps Its Consensus Engine Tuesday. 150ms Is a Target, Not a Result.

2026-10-20 1:36:59

Blockchain

One Withdraw, Paid 29 Times: Reentrancy, Read Line by Line

2026-10-30 2:35:43

❯
Profile
Cart
Coupons
Search