<- Back
Comments (117)
- mawadevThat is a case I only become aware of when I read blogs like this. Technically I could solve it the same way, but these days you have so many tasks on your desk, you don't think about the problem and implications at all and that awareness/discipline is drowned in the noise/unlearned over time.If someone only gave me 2 minutes for this, because they think it is very simple (as always), I'd have done a count of files of a specific pattern in the directory and then picked a random index, very naive and quick and dirty programming, no sampling at all, just to avoid discussions why it takes so long with people who don't want to hear it.This reminds me of when I did a lot of C#, Java, JS, Python in my life, filling maps of strings and objects until I started with zig and noticed how expensive and complicated strings and data structure allocations can be. It kind of blew my mind how much memory and computation we waste when we try to get stuff done as fast as possible because of budget/time constraints.
- lyorigMan, every post from Raymond Chen regarding Windows internals is like a little Xmas. I wonder whether he has to ask someone for permission before publishing this knowledge, though.
- EMIRELADEROFor those interested, here's the actual code Chen talks about: https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b...
- scrumperThis is a fun example of the cognitive switch you have to employ when first starting to program a computer. It's extremely easy for a human to pick at random one thing from a pile of things: you reach out your hand and grab it, maybe swirling them around on the table first to shuffle the order. For a computer, there's no direct analogy to that. They just can't do it. And the human process is nothing even slightly like the one the computer follows: we don't have to count the sets and iterate over them, or count the items and then generate a random number to pick the nth item, or risk picking a null item.
- impoppy>Raymond has been involved in the evolution of Windows for more than 30 years. He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.
- cgioThe times when people spent an extra brain cycle to avoid billions of second passes.
- ape4It's somewhat odd that filesystems don't have a call to tell you how many files are in a folder.
- riettaI love the understated "some time ago" linking to a 2004 blog post. Raymond has been at this a long time :-)
- ulrikrasmussenBut the naive way of doing this also wouldn't really require two passes, right? It would just require more memory because you would first save all file names in an array (stopping at 100), then pick a random one in constant time.
- jasonvorheA couple of screenshots would've been useful for the post-millennial generations that never got to see the "beauty" (cough) of XP.
- bayindirhHonestly,I don't understand Microsoft. These guys solve the most mundane problems with most elegant solutions and with sound edge-case handling scenarios, then they destroy all the effort with subpar programming where it matters and with user hostile behavior where they can't botch it.
- Aditya_0315What is amazing is the amount of consideration given to an issue which would escape the majority of users. It is surprising how complex an apparently easy process turns out when considering certain special cases.
- bhaney100 seems like a very unnecessarily low limit, even for the time
- KellyCriterionWhy they made it that complex?A simple rand/mod based on first character of username should be sufficient?
- dsegoWhy doesn't it return on the first match?
- bombcarDoes it also check existing users so you don't match one?
- moritzwarhierSome say the Admin account defaulted to a chessboard.I think it's true, but not sure if I'm just falling victim to false memories... help?
- frou_dhI'm disappointed that it is not influenced by the username ... "You sound like a skateboard kinda person"
- wky[dead]
- vishnuaniyan[dead]
- anonundefined