FIFO vs LIFO

fifo

In college I had three computer classes where we spent a ridiculous amount of time in each learning the difference between FIFO (First In First Out) and LIFO (Last In First Out). It’s an important concept, if you are one the very few people who ever encounter a LIFO situation.

I used it once in my programming career, and that was just because of the way an insane boss wanted a report structured.

However, after reading Einstein’s opinion that if you can’t explain something simply, you don’t understand it well enough, I realized that the difficulty wasn’t with the students, but with the teachers.

They all used elaborate analogies that did not hold up to scrutiny. Being the OCD asshole I am, I decided a better analogy was needed. If only to satisfy my own need for order.

For my demonstration, I have three marbles, a test tube, and a same-sized tube open at both ends.

FIFO: The marbles roll into the tube and come out the other end in the same order.


first in first out

LIFO: The marbles roll into the test tube. The test tube is turned around and the marbles roll out in the opposite order from which they entered.