Ping

EVENT — do this WHEN that happens. An event handler registers on a trigger and then rests at zero cost until the trigger fires — it does NOT poll (ask over and over); it waits to be told. Event-driven, not a busy-loop.

Loading audio…

Press play to listen along. The line being read lights up as you go.

Show full transcript

Loading transcript…

01 Opening
Ping beat 1 of 5

On the corner of Loop's workbench hung a small brass bell, and it was doing absolutely nothing — beautifully. All morning: sunlight crossing the bench, a moth at the window, Loop shuffling papers, and the bell just hanging on its hook, silent, patient, not a shiver. Beside it a card read, in Loop's tidy hand: WHEN struck → run this. A new kid drifted over and frowned. "That bell's broken. It's not doing anything." "It's the busiest thing in the room," Loop said, not looking up. He reached over and flicked it. Ping! — one bright note — and the instant it rang, Bit, the little robot at the bench's end, snapped its arm up and beeped. The kid jumped; the bell went still. "See that? It waited. It didn't check the room a hundred times a second asking is it time yet, is it time yet. It hung there, resting, costing nothing — until the exact instant it was struck. Then, and only then, it ran. When this happens, do that. That's Ping. That's an event."

02 Ping
Ping beat 2 of 5

The kid wanted to know why it only ran when struck — why it didn't just run on its own like everything else she'd built. So Loop told her about Trek, the loop one shelf over: a little walking gear that went around and around, doing its work over and over, never resting. "Trek is wonderful," Loop said, "but Trek never sits still. Ask Trek to watch for a button and Trek will ask is it pressed? is it pressed? is it pressed? forever — thousands of questions a second, and almost every answer is no. That's called polling, and it burns the machine down doing nothing." He set Ping and Trek side by side. Trek whirred; Ping hung silent. "Ping does it the lazy-clever way. Ping doesn't ask — Ping waits to be told. You register it on a trigger, you write down the code to run, and then Ping does the hardest, cheapest thing there is: it does nothing, perfectly, until the one moment that matters." He smiled. "Nothing is a great deal of work when you have to do it exactly right." The kid looked at the silent bell with new respect. It hadn't been broken. It had been ready.

03 Ping
Ping beat 3 of 5

The kid decided a bell that quiet belonged at CodeRealm, where they studied the parts a program is built from, so she carried Ping down to Loop's classroom and hung it by the door. Loop didn't ask her to prove Ping was clever. He asked one thing. "What is an event?" She didn't answer with words. She hooked Ping to a big red button, pinned a card beside it — WHEN button pressed → Bit spins — folded her arms, and waited. Nothing happened. The bell hung quiet. Loop raised an eyebrow. "It's not doing anything." "It's registered," she said, and pressed the button. Ping! Bit spun a fast, happy circle and stopped. "It didn't run until the trigger. It waited for one specific thing, and when that thing happened, its handler ran. That's all." Loop watched Bit come to rest. "You belong here."

04 Ping
Ping beat 4 of 5

Ping's corner soon filled with quiet, waiting bells. A boy came in one afternoon, stuck and grumpy. He'd built a game where a robot was supposed to react, but it just sat there. "I told it to jump, and it does nothing. I did all the work and it does nothing." "Show me." His program had Bit asking, over and over, did they press it yet? did they press it yet? — so busy polling that it never had a spare moment to actually jump. "It's exhausting itself," the kid said. "Let's give it bells instead." She hooked one Ping to his button — WHEN button pressed → Bit jumps — and added two more: WHEN sensor covered → Bit lights up and WHEN 5 seconds pass → Bit spins. Three handlers, all hanging silent, each registered on its own one trigger. "Now press it." He pressed the button — Bit jumped, the very instant his thumb hit the key. He covered the sensor — Bit lit up. He held his breath, waited, and after five seconds Bit spun on its own. "Every one answered the second I did it," he said, grinning. "It feels alive." "That's the trick. You stop asking a thousand times, and you wait for the strike. When this, do that."

05 Closing
Ping beat 5 of 5

Later, when the room was empty, the boy came back, quieter now, watching the row of silent bells. "When they're just hanging there — not ringing, not doing anything — how do you know they're still working?" The kid thought about the first bell she'd called broken. "You feel it when it fires. That's the honest answer. There's a bright little jolt — you press the button and the thing answers right then, the exact instant you made it happen, and it feels wonderful. Quick. Awake. Like the program was listening the whole time." She looked at the row of quiet bells by the door. "They're not doing nothing. They're doing the patient thing — registered on their triggers, resting at zero cost, waiting for their one moment. And when it comes, they don't miss it." The boy nodded and headed off still grinning at how fast Bit had answered. Behind him the bells hung silent, ready, each listening for the strike that would wake it.

The CodeRealm ensemble

Ping is part of CodeRealm's distributed-narrative cast. Each character embodies a different curricular primitive; together they teach the full subject.