is notoriously difficult to reason about (thank you Satoshi)
Note that it is difficult to reason because it is a stack-based minimalistic language. It has definitely some shortcomings, also because we wanted soft and not hard forks (I think it is safe to claim that all the <xyz>VERIFY patterns replacing OP_NOP* in script extensions is caused by that, but happy to be proven wrong about that.)
OP_IF has been one of the op-codes used in Bitcoin script since the very beginning
Real world usage came when Peter Todd proposed CLTV. It's basically what enables the L in HTLC for lightning too (though we use CSV for that - relative locktime): the lock is conditional (and the way we often express conditions in programming is with if).
Note that it is difficult to reason because it is a stack-based minimalistic language. It has definitely some shortcomings, also because we wanted soft and not hard forks (I think it is safe to claim that all the
<xyz>VERIFYpatterns replacingOP_NOP*in script extensions is caused by that, but happy to be proven wrong about that.)Real world usage came when Peter Todd proposed CLTV. It's basically what enables the
LinHTLCfor lightning too (though we use CSV for that - relative locktime): the lock is conditional (and the way we often express conditions in programming is withif).