News for hackers. Stuff that matters.
Re:Why modern software is slow by ComputerGuru on Thursday September 29, 2022 @11:49PM (#33030681)
Forget background threads. People don’t know basic programming principles. The thought of debouncing user input didn’t even occur to them.
Re:Why modern software is slow by rustybolt on Friday September 30, 2022 @12:42AM (#33031041)
What do you mean by 'debouncing' here? I only know it as ignoring keypresses of the same key/button that happen too fast after each other (because they are likely a mechanical or electrical glitch rather than the user actually meaning to press the button/key multiple times).

If you mean that, I don't know how it relates to the comment/article since I never needed to do debouncing in a desktop context (only for embedded stuff with actual push button circuitry attached).

Re:Why modern software is slow by kiawe_fire on Friday September 30, 2022 @01:14AM (#33031284)
That same concept, but one step removed if you will.

The classic example is a data table with a text field that filters/searches the results, pulled from a server.

Let’s say you want the results to update “live” as the user types, without having to click a “search” button. So if the user types “bacon” then she sees all results that contain the word “bacon” in them.

Problem is, if the act of sending the text field input to the server and waiting for the results is relatively slow and blocks the UI from updating, then each key press causes a delay between the search results updating on the screen, and the next letter showing up in the search field.

1. User types “b” and then the app sends “b” to the server, pauses, gets a response of all results with the letter “b”.

2. User types “a”, and the app sends “ba” to the server… pauses… gets results. She types a “c”, the app sends “bac”, etc.

Debouncing, then, means the app waits a short period of time to make sure the user is finished typing before sending the search term.

Usually this means every time the user enters a letter into the search field, the app sets a timer for, say, 500ms. If the user doesn’t enter another letter for 500ms, great - send the search term, wait for the results.

If the user does enter another letter within 500ms, then she must still be typing, so reset the timer back to 500ms and hold off on sending the search term out to the server.

Re:Why modern software is slow by edflsafoiewq on Friday September 30, 2022 @01:13AM (#33031277)
Same idea, debouncing replaces a sequence of "re-render Markdown" events (button pushes) with a single "re-render" event (button push). Googling "debouncing" will turn up a bunch of articles about it.
Re:Why modern software is slow by foobiekr on Friday September 30, 2022 @12:34AM (#33030987)
This. Incredible. Debouncing was done in the early 70s and even someone on;y familiar with more modern similar ideas would note that Nagling was invented in 1984 at the latest...
Re:Why modern software is slow by stingraycharles on Friday September 30, 2022 @12:40AM (#33031029)
Not a UI / frontend developer. Doesn’t denouncing user input increase the latency before changes are rendered onto the screen?

I would expect the changes to be visible ideally in the next frame, but I guess that’s not really an option?

Re:Why modern software is slow by wtallis on Friday September 30, 2022 @01:04AM (#33031198)
Debouncing only has to carry a latency penalty for certain kinds of responses. A good UI should be able to start processing an action as soon as the button goes down, and add/amend the actions later once it's clear whether it was a press and hold, press and release, or double-click. If the appropriate responses to those three options are mutually exclusive to the point that the UI can't respond at all until the user input is fully disambiguated, then the keybindings are probably ill-considered and those unrelated or conflicting functions should not be sharing a button.
Re:Why modern software is slow by ComputerGuru on Friday September 30, 2022 @01:01AM (#33031176)
In the strictest sense, yes. But here clearly rendering is taking longer than 1/60s so it wouldn’t matter.

The compromise would be to always start rendering immediately rather than wait x ms, but if you detect that the previous rendering hasn’t completed when the next input has arrived then you can start debouncing before rendering until you catch up.