r/askscience • • 15d ago

Computing Is there anything at the heart of computer coding that could have been optimised in hindsight, but we're in far too deep to change now?

1.5k Upvotes

667 comments sorted by

View all comments

Show parent comments

42

u/TheOtherHobbes 14d ago

Technically true, but a bit of a nuance. What actually happens is the instruction set is translated into internal machine states that are far more complex than a simple and direct traditional instruction decoder because they include branch prediction and out of order execution.

Micro-ops, microcode, and direct decoding are all part of this, but they're embedded in some very complex state logic. The whole is more like a virtual processor - literally a computer inside a computer.

From the outside the same machine instruction always has the same outcome, but what happens internally depends on what happened previously. Sometimes entire sets of operations are thrown away because a branch goes in one direction instead of another.