惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
量子位
博客园_首页
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Forbes - Security
Forbes - Security
IT之家
IT之家
N
News and Events Feed by Topic
S
Security Affairs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Webroot Blog
Webroot Blog
Recorded Future
Recorded Future
L
LangChain Blog
Y
Y Combinator Blog
AI
AI
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google Online Security Blog
Google Online Security Blog
V2EX - 技术
V2EX - 技术
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
I
Intezer
T
Tenable Blog
G
Google Developers Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
有赞技术团队
有赞技术团队
O
OpenAI News
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Last Week in AI
Last Week in AI
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
Blog — PlanetScale
Blog — PlanetScale

Unsung

The surprising richness of GarageBand – Unsung “The pipeline of future experts is thinning from both ends.” – Unsung “It took months to find appliances that didn’t need apps to function.” – Unsung Day for night – Unsung “But obviously, that’s just silly stuff.” – Unsung Within or without – Unsung A few interesting modern pixel fonts – Unsung Google Docs shortcut onboarding – Unsung “Why pay for an orchestra when your computer can do it all?” – Unsung Lisa’s copy (and cut, and paste) – Unsung “This is a common tell in web apps, and we did a lot of work to eliminate it.” – Unsung Chrome’s abnormal tab search – Unsung “Some say it sounds like an alto saxophone.” – Unsung Shallow breathing – Unsung “If you just ignore those pesky impossible details, the demo looks deceptively simple.” – Unsung “Accents are an opportunity, not a burden.” – Unsung Less doesn’t need more – Unsung “Easy to use,” the hard parts – Unsung “We accepted this gradual bloat, but that’s not progress.” – Unsung Safari and system design, pt. 1 – Unsung “193 hours of attempts (and practice)” – Unsung Not a radio pharma ad – Unsung “Cryptic mode was born from a hard constraint.” – Unsung Speaking of wiggling the mouse – Unsung “This is where your mouse becomes a cryptographic instrument.” – Unsung Mailbag: Photoshop’s focus post – Unsung Rug pulled – Unsung Save For Web claws – Unsung “Nothing short of a magic trick” – Unsung “They did the bare minimum and moved on.” – Unsung A preview of the future – Unsung Peaked in 2015 – Unsung “There seems to be a file that is just filled with undecipherable Morse.” – Unsung “This was a user-friendly computer.” – Unsung “Watchmaker’s delicate precision and ornate mechanical intent” – Unsung “Traditionally, fonts were just shapes.” – Unsung “Who thinks about a screwdriver?” – Unsung The land where time stood still – Unsung The vision of persistence – Unsung The 1990s called and they want their dialog box back – Unsung “Have you ever been annoyed by your Mac’s media keys?” – Unsung Early names – Unsung Mouse pointer as a mere mortal – Unsung “Examining the changelog in its entirety would be a massive task, given that it was now over 200,000 words long.” – Unsung CleanShot’s onboarding via settings – Unsung The tortoise and the hare live on – Unsung “The Helvetica of music notation” – Unsung Photoshop’s challenges with focus, pt. 2 – Unsung About Unsung: Thanks for your feedback! – Unsung Book review: Shadow of the Colossus (Boss Fight Books) – Unsung UI art from 4096 – Unsung Tactical dark modes – Unsung What deserves a second chance – Unsung “The cheatsheet you won’t need.” – Unsung “That’s how floating point errors and triangle numbers solved a mystery.” – Unsung “Plain text has been around for decades and it’s here to stay.” – Unsung Abort, Retry, No, Thanks – Unsung “The deeper you look, the more it starts to feel like a platform.” – Unsung Out of touch – Unsung Recency bias (non-derogatory) – Unsung “You could key smash, and it would type out the thing.” – Unsung “The fancy software figures it out for you.” – Unsung Got your back, pt. 5 – Unsung If a feature falls in a forest – Unsung “The system is so twisted that even Apple itself begs for these reviews from its own apps.” – Unsung “It can be really disorienting to scroll around a fully monochrome hexdump.” – Unsung Raycast’s confetti cannon – Unsung The edge not taken – Unsung “Area connected to a given node in a multi-dimensional array with some matching attribute” – Unsung “Use links, don’t talk about them.” – Unsung Unsung @ 250: Please send me your feedback! – Unsung Unsung @ 250: Nine design details – Unsung Unsung @ 250: Goals and principles – Unsung “To build a thing that immediately feels like you’ve had it forever is very hard to do.” – Unsung “Should be no trouble at all for a driver to understand.” – Unsung Thoughtful file dropping in Wakamaifondue – Unsung “Rather than trying to fix this mistake, the developers leaned into it hard in the sequel.” – Unsung The beauty and the terror of oddly-specific commands – Unsung “We can have the best of all worlds.” – Unsung In search for a more precise cursor – Unsung “Deere charges six figures for a tractor. But the farmers were still the product.” – Unsung Is this the latest? – Unsung “So I wrote a script that takes monthly screenshots of Google and Apple Maps.” – Unsung Only time will tell – Unsung “Approximately 21 times the estimated age of the universe” – Unsung “We’re trying to copy this old machine, weirdness and all.” – Unsung “Software is a unique art because it is so reactive.” – Unsung Blink comparators in photo editing apps – Unsung “Prototyping turned into an excuse for not thinking” – Unsung “Every step they take, in every single direction, is right on top of a rake.” – Unsung “Subtle line between animations that help and animations that hurt” – Unsung Why do Macs ask you to press random keys when connecting a new keyboard? – Unsung “And if I were to end this story here, this would be a great story.” – Unsung “If you use your computer to do important work, you deserve fast software.” – Unsung “It moved too slowly to be an asteroid.” – Unsung Linear’s clever internal redesign UI – Unsung “I’m hoping that the listeners out there, when they hear it, they’ll feel seen.” – Unsung For your consideration: Tab to fix spelling – Unsung Anachronisms – Unsung Testing tip: Enable the zoom peek gesture – Unsung
I was wrong about Duff’s device – Unsung
Marcin Wichary · 2026-06-25 · via Unsung

Duff’s device is a C language technique that looks like this:

send(to, from, count) {
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}
}

It achieves two things:

  • It unrolls the loop in chunks of eight. Unrolling the loop is when instead of telling the computer “do X 5 times,” you say “do X do X do X do X do X,” trading some code readability and memory usage for higher speed.
  • It cleverly (ab)uses a property of the C language to unroll the remainder of the loop, which normally would be impossible to do as the remainder is less than 8 and different every time. It does so by basically overlapping a do/while loop atop a switch/case structure in a way that should come with a coding equivalent of a parental warning.

I always assumed the technique is from the 1970s and was just a show-offy thing that didn’t serve any function, a “look how clever I am” from a programmer who was perhaps just a touch too nerdy. But yesterday, I found a 1988 message from its inventor, Tom Duff, and it turns out I got almost everything wrong.

First of all, the technique was from 1983, when Duff was at Lucasfilm – much later than I expected.

Second of all, it actually solved a problem. Duff’s device wasn’t just making things faster abstractly, but actually fixed a user-visible performance issue. “[The loop before applying the device] was the bottleneck in a real-time animation playback program which ran too slowly by about 50%,” writes Duff.

Most importantly, however, Duff himself had mixed feelings about it:

Disgusting, no? But it compiles and runs just fine. I feel a combination of pride and revulsion at this discovery.

I recognize this set of feelings from many different software hacks I invented in my life. I think it’s important to carry them all with you – not fall in love with the hack and continue seeing it for what it is (and what it will be in the future as code ages), but at the same time not be above using it if it’s solving a real issue.

Also, Duff adds:

Many people […] have said that the worst feature of C is that switches don’t break automatically before each case label. This code forms some sort of argument in that debate, but I’m not sure whether it’s for or against.

I can’t speak for C, but I have always felt frustrated about JavaScript stealing that convention – it’s so error-prone, and in my many years programming in it, I have never had to use a Duff’s device or anything else that benefitted from it.