Live data from Hacker News

What algorithm did Windows XP use to choose your initial user picture?

devblogs.microsoft.com

101–110 of 168 posts

Re: What algorithm did Windows XP use to choose your initial user picture?

#101
post #60
post #50

It's somewhat odd that filesystems don't have a call to tell you how many files are in a folder.

Either that call would have to do the same (i.e., walking the files and counting), or you'd need some additional metadata in the directory entry to store how many files there are, requiring additional storage accesses for adding and removing files. Adding to that that both FAT32 and NTFS are quite old and had to run on older hardware. Cycles and disk accesses are not free. On top of that, how often is it necessary to…

Not that it counters any point you're making, but ZFS displays the number of contained entries of a directory in the directory's size field; mind that . and .. are included, so you usually need to subtract 2 to get the count you actually want. I do find it useful sometimes to know the count without getting the listing; the former is a very inexpensive operation (since ZFS is keeping track of metadata like you suggested), the latter is expensive, potentially extremely with hundreds of thousands or more of entries.

This is more-or-less unique to ZFS. Other file systems even on Linux and FreeBSD generally don't provide this behavior.

Re: What algorithm did Windows XP use to choose your initial user picture?

#103

Earlier quoted context omitted.

Took me years to like Windows XP. Hated the new start menu. I always kept installing Windows 2000 (or ME, probably because it could use Windows 98 drivers but look like Windows 2000). I eventually got used to it and ended up liking it.

IIRC correctly, XP’s stability greatly increased after Service Pack 2 was published.

XP Service Pack 2 was in essence a different OS.

Re: What algorithm did Windows XP use to choose your initial user picture?

#104

But 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.

How do you know how big your array has to be in a single pass? I don't think the WinXP source uses vectors or similarly ergonomic auto-growing arrays. You could preallocate an array big enough for 100 paths of length MAX_PATH, but that's a bit wasteful. And it doesn't sound like you'd actually end up with fewer lines of code (in that flavor of C++, in python it would be different)

Re: What algorithm did Windows XP use to choose your initial user picture?

#105
post #101
post #60

Earlier quoted context omitted.

Either that call would have to do the same (i.e., walking the files and counting), or you'd need some additional metadata in the directory entry to store how many files there are, requiring additional storage accesses for adding and removing files. Adding to that that both FAT32 and NTFS are quite old and had to run on older hardware. Cycles and disk accesses are not free. On top of that, how often is it necessary to…

Not that it counters any point you're making, but ZFS displays the number of contained entries of a directory in the directory's size field; mind that . and .. are included, so you usually need to subtract 2 to get the count you actually want. I do find it useful sometimes to know the count without getting the listing; the former is a very inexpensive operation (since ZFS is keeping track of metadata like you suggest…

ZFS being a copy-on-write fs probably made the relative cost of that feature much cheaper

Re: What algorithm did Windows XP use to choose your initial user picture?

#106

A couple of screenshots would've been useful for the post-millennial generations that never got to see the "beauty" (cough) of XP.

Here's a blog post from 2003 with beautiful pictures. https://jakeludington.com/2003/12/17/create_your_own_windows...

These pictures are so compressed they depict color rasterization artifacts more than the Luna UI style.

Re: What algorithm did Windows XP use to choose your initial user picture?

#107
post #20

That 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…

Counterexample: desktop icon layout in quadratic time: https://randomascii.wordpress.com/2021/02/16/arranging-invis...

Its not like windows is the pinnacle of software craftsmanship.

Re: What algorithm did Windows XP use to choose your initial user picture?

#108
post #82
post #69

Earlier quoted context omitted.

Because it would always return the first match in that case. You still need to see all of the items once. Imagine you have 2 items. First one has 100% chance to be selected. So it does. Then the second has 50% chance to be selected. If it isn’t you effectively chosen the first one and have 50/50 chance to return either. Now you add a third item. There is 50/50 chance of having either selected. And 1/3 chance of repla…

Thank you for writing this out, I didn't quite get what was going on at first. But then, to formalize the recursion from your example: let's assume we're at item n in the iterator, and at that point we've selected a winner from the previous n-1 items with equal probability, i.e. each item had a 1/(n-1) chance of being selected. The probability that item n will override it is 1/n. The probability that the old winner w…

An alternative wording for the same idea:

If you are at picture 1, you have 100% chance of selecting it as the current winner.

If you are at picture 2, you have 1/2 chance of selecting it as the current winner, or 1/2 chance of keeping the previous fairly selected winner.

At picture 3, 1/3 chance of picking it, or 2/3 chance of retaining the previous fairly-selected winner. There are two of them, so 1/3 chance of each.

At picture n, you have a 1/n chance of picking it, or an (n-1)/n chance of retaining the previous fairly-selected winner. There are n-1 previous pictures, so all of them have had 1/n chance of being picked.

At every single step, there is the invariant of all pictures being considered that far having had an equal chance of being selected, and the next step always retains the invariant.

Re: What algorithm did Windows XP use to choose your initial user picture?

#109
post #27

Man, 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.

If you ask for permission on something like this the answer is always no.

Re: What algorithm did Windows XP use to choose your initial user picture?

#110

Honestly, 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.

That's simple. The Windows Kernel is a collection of mostly elegant solutions, with a strong peppering of backwards-compatibility cruft, all the way from NT3 to Windows 11. The Windows userland received a lot of effort until about Windows XP, and since then is a collection of subpar programming, half-finished projects and user-hostile patterns (with some notable exceptions)

Different teams with different goals and different management

Post reply on HN