Scratch's Hidden Glitch: Dragging a Character Can Break Kids' Code
Same code, different computer, different result — and no one knows why.
Tens of millions of children program in Scratch, whose programs are concurrent: when the green flag is clicked, every sprite's scripts start together and share the project's state. Which script starts first is decided by the sprites' front-to-back stacking order, which no block reads. Dragging a sprite brings it to the front, and that order is saved with the project — so a program can work on the author's screen and fail on the teacher's, with the same blocks. The researchers' tool, StackSwap, runs a project under these orders and returns a two-run witness naming an adjacent pair of sprites whose swap changes the outcome. On 767 real programs from a course, an online judge, and a random public sample, 26.4% (course) and 18.2% (public) of those with a scheduling choice behave differently under some stacking order.
- In Scratch, which character's code runs first is decided by front-to-back stacking order — something no block in the program can see or check.
- Dragging a character changes that order and it gets saved, so roughly 1 in 4 tested student projects behaved differently under some order.
- The authors built StackSwap to test every possible order and recommend Scratch show this order so kids and teachers aren't confused.
Why It Matters
Your child's working project may fail at school through no fault in the code itself.