Skip to content

Instantly share code, notes, and snippets.

@androidfred
Last active January 8, 2024 20:23
Show Gist options
  • Save androidfred/75629dfda63180b6f0a0eaa4655ec5f0 to your computer and use it in GitHub Desktop.
Save androidfred/75629dfda63180b6f0a0eaa4655ec5f0 to your computer and use it in GitHub Desktop.
This "progressively more detail" image loading algorithm can help you do and learn anything

This "progressively more detail" image loading algorithm can help you do and learn anything

Summary, TLDR

When doing or learning pretty much anything, the strategy where you tackle the whole thing all at once, but starting with a rough outline and then incrementally revisiting everything to go into increasingly more detail, is often more effective than doing things perfectly little by little and missing the big picture. (pun intended)

Longer version

Back in the days of dial up internet, which was very limited in speed and capacity compared to modern internet connections, images on a web page could take very long to load. There were different strategies for dealing with that problem, and if you look hard enough (pun intended again), they can reveal some things about how to do and learn stuff.

The perfectionist strategy

One strategy was to render the images pixel perfect, line by line.

Lorem ipsum dolor sit amet, consectetur adipiscing.

X X X X X X X (<-- X's are lines of pixels as the image loads)

Ut enim ad minim veniam, quis nostrud exercitation.
Lorem ipsum dolor sit amet, consectetur adipiscing.

X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X (<-- image has finished loading)

Ut enim ad minim veniam, quis nostrud exercitation. 

^^^
this content would have been shifting down for every 
line of image rendered, which makes it hard to read

The problem with this approach is, because it takes a long time to load the images, for most of the time the images are loading, you have no idea what they depict, and as they're loading, they will cause annoying content shift for whatever comes after them, making getting on reading the page in the meantime impossible, even though it otherwise could have been read just fine much sooner if only a better rendering strategy was adopted.

The progressively more detail strategy

Another strategy was to render the whole image in steps with progressively more detail, starting with a rough mosaic blob with the same dimensions as the final image, then improving the resolution of the entire image little by little.

\         / (<--blob of single pixel)
  \     /
    \ /
    / \
  /     \
/         \

Ut enim ad minim veniam, quis nostrud exercitation. 

^^^ no shifting of content
\   / \   /
  X     X   (<-- Rough mosaic with four pixels)
/   \ /   \
\   / \   /
  X     X
/   \ /   \

Ut enim ad minim veniam, quis nostrud exercitation. 

^^^ no shifting of content
X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X
X X X X X X X (<-- image has finished loading)

Ut enim ad minim veniam, quis nostrud exercitation.

^^^ no shifting of content

The advantage of this strategy is you can immediately see the big picture (even if it's rough and lacking in detail) and immediately get on reading the page just fine. (because there's no content shifting)

So what? What's the point?

When we do anything, it's tempting and easy to default to a perfectionist, "all or nothing" mindset that's ultimately unproductive, even harmful.

But the point of this post is not only to advocate for a "little by little" approach. After all, both strategies employ a "little by little" approach, just in different ways.

The subtle and important distinction is that the "progressively more detail" strategy enables and encourages

  • immediately seeing the big picture
  • immediately getting on (even if initially there isn't that much detail)
  • knowing when you have just enough detail, so you don't waste time reaching unnecessary levels of detail

whereas the perfectionist strategy

  • completely loses track of the big picture throughout the whole process
  • doesn't allow much getting on with much if anything until everything is complete and perfect
  • risks wasting lots of time reaching levels of detail that could easily turn out to be unneccessary

The adages "missing the forest for the trees" and "anything that's worth doing is worth doing poorly" kind of get at the same thing. (but to be honest, I have yet to find a way to succinctly describe the idea I'm getting at here)

Some more real life examples

Learning geography

Imagine you want to teach someone geography. You can either start by saying "this is the Earth", then "this is Africa, this is Eurasia, these are the Americas", then "this is Europe, this is South East Asia, this is North America" etc. That way, every step covers the big picture, no matter how imperfectly, and is immediately useful.

Or, you could insist on teaching country by country, completely losing track of the big picture and any usefulness of each individual step.

Dance?

A couple of years ago, I wanted to learn Latin dancing. I quickly got stuck trying to execute each move perfectly, not wanting to move on to the next until I had "mastered" the current one, effectively both completely stopping myself from seeing the big picture and killing all progress.

Eventually I gave up trying to execute each move perfectly, instead trying to familiarize myself with the entire domain of steps (albeit imperfectly), and then incrementally revisit and improve them.

This led to a huge boost in understanding of each style (because, for the first time, I wasn't stopping myself from seeing the big picture) and enabled me to progress much, much faster. (I'm still no master, but there was definitely a big improvement)

Exceptions

Of course, there are many cases where this strategy isn't feasible! Eg, if you're building a skyscraper, it's not desirable or possible to erect "a rough version" of the entire building in the first step, and then "incrementally improve on it". You HAVE to first lay a foundation, and it HAS to be perfect, and then keep adding floor by floor with no imperfections, or the whole thing will collapse!

But software and many other contexts are not like that! So if you can use the progressively more detail strategy, give it a try and see if it helps!

@Wazdoes
Copy link

Wazdoes commented Oct 7, 2021

This is great and reminds me of what our team is doing at times.

@androidfred
Copy link
Author

Thanks for the kind words, glad it was useful to someone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment