Like a lot of people, I get these terms confused. I know they’re both strategies for taking events that fire a lot — like
onscroll — and limiting how often you listen to them, but the specifics constantly slip my mind.
To solve it once and for all (for me), I looked up what “throttle” and “debounce” meant before computers. Computing is a such a new field that most of its terminology is borrowed, often only one generation removed. And then usually mangled and removed far from the point. Or some horrible mathematics word that’s so metalinguistically abstract it makes my face hurt, like “arity” and “tuple”.
But I digress.
“Throttle” means two things in English, depending on if it’s a noun or a verb.
As a noun, “throttle” derives from Old English for “little throat”. throt + -le → throat + little. Something like that.
The verb is related, but different. It’s a slightly nicer synonym for “strangle”. Strangling implies death, but throttling something is more like roughing up its windpipe a bit. That’s real morbid so let’s gloss right on by 😶
Gasoline motors have a part called the throttle. (You may have heard of a part called the choke, but that’s something entirely different and only serves to confuse us.) In this case an engine’s throttle is its little throat — the valve it uses for oxygen intake. The more oxygen, the faster the engine spins, as it ignites gasoline more quickly.
In older cars, the accelerator pedal connected directly to the engine’s throttle. The further you pressed the accelerator, the wider the throttle opened, increasing the amount of oxygen available. “Full throttle” is when the oxygen intake is at its highest, and the motor is running as quickly as it can.
Bear with this next bit — it’s a subtle antonym for the same word.
Easing off the accelerator pedal “throttles down” the motor — as its oxygen supply is restricted, the engine runs slower and slower. So even though full throttle is when the engine breathes freely, throttling the engine goes back to the strangling metaphor. This meaning spread from gas motors to other engines and eventually became a generic term to mean limiting how quickly something happens:
When a driver throttles the engine, they slow down its revolutions-per-minute.
When your ISP throttles your bandwidth, they’re restricting your download speed.
A throttled event is one that’s limited to fire no more often than a certain rate.
After all that, it’s refreshing how much more straightforward “debouncing” is. And less strangly.
Have you ever flipped a light switch and noticed a brief flicker of darkness for a split second? That’s called a contact bounce, and it’s quite literal.
Most switches use springs to keep their position, and when you overpower the spring to flip the switch, the electrical contacts really do bounce off each other as the spring settles. For simple electric devices like lightbulbs or kettles, that just means a flicker. But for more complicated systems like computers, a contact bounce means what you intended as Off → On is heard as Off → On → Off → On → …
In electricity-land, this is fixed by modifying the circuit to reduce the bouncing into one signal (usually via a capacitor). That’s “debouncing” the switch. No matter how many times the event happens, the receiver only hears about it once.
Usually the debouncing only collapses events within a few milliseconds. You may want to flicker the lights manually, so ignoring repeated switch flips for too long would get in the way.
A debounced switch is modified so that it seems to change its electrical circuit only once.
A debounced ball is deflated so it hits the floor with a splat instead of coming back up.
A debounced event collapses multiple events in a certain timespan into just one.
What about “slugmifying”?
See me after class.