6 ms·
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
by mawadev 6d ago
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 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.
- cabirum 6d agoCounterexample: desktop icon layout in quadratic time: https://randomascii.wordpress.com/2021/02/16/arranging-invisible-icons-in-quadratic-time/ https://randomascii.wordpress.com/2021/02/16/arranging-invis... Its not like windows is the pinnacle of software craftsmanship.
- kevin_thibedeau 6d agoI'd bet this bug also shows up in Vista file explorer with auto arrange disabled. Nobody will ever need more than 100 icons on their 800x600 workstation. Ship it.
- Aurornis 6d agoTwo things that have helped me with quickly recognizing these situations: Programming for MCUs. Less so today when multi-hundred MHz MCUs are cheap, but even several years ago there were a lot of products where you needed to use the cheapest MCU and everything it did had to be optimized to avoid stalls and edge cases. Second is doing LeetCode problems for fun/practice. This will elicit a groan from a lot of people, but the algorithms and pathological edge cases you learn really do change your thinking. The most interesting ones are the hard problems where they’ve added some hidden test case that causes naive solutions and algorithms to blow up. You start thinking on high alert for edge cases and Big O problems. It’s more fun when you’re doing it to learn on your own than for forced interview prep.
- CamperBob2 6d agoHow many user pictures are there to choose from, though? This is a nice, elegant way to sample from the set, but the nature, size, and frequency of the problem don't justify more than five or ten seconds' or thought and one or two minutes of coding.
- dwattttt 6d agoBut multiplied by the number of times it'll run on the planet, and you have a surprisingly big impact.
- mawadev 6d agoExactly this, if you count the amount of time the windows 11 context menu needs to pop up and then the second click to get to the old context menu across the entire globe for a month, you would get an insane amount of time and cycles wasted
- CamperBob2 6d agoI guess I'd do it once, the slow and easy way, and cache the result. But that's just me.
- dwattttt 6d agoThe billions of times aren't repeated times for the same person, it's because it's been done for the first time billions of times. This is the "choose a user's initial profile picture". They're not randomly changing it.