There's an art to creating the perfect ice cream soda. Although you start with just two ingredients--ice cream and soda--you end up with three--ice cream, soda, and foam.
An A Moment of Science listener and ice cream soda aficionado noticed something curious: When he put ice cream in his glass first, then poured soda over it, his glass filled with too much foam. Put the soda in first, and he hardly got any foam at all!
As it turns out, there's a big difference between foam on a glass of plain old soda, and foam made by soda and ice cream together. When ordinary soda foams, it releases carbon dioxide gas. This forms bubbles that rise and pop pretty quickly. Things get more complicated when ice cream is added to the mix. This is because ice cream itself is in fact a kind of foam.
If you looked at ice cream under a microscope, you'd see ice crystals, liquid, and air pockets. This foamy mixture of liquid, solid, and air is crucial to ice cream's flavor and consistency. To help keep this foamy microscopic structure, ice cream contains chemical ingredients called "thickening agents." These are designed to help foam stay foamy.
When you pour soda over ice cream, the soda makes its bubbles as it usually does. But these bubbles don't just pop; they are held in place and stabilized by the thickening agents in the ice cream. You get a glass full of thick ice cream soda foam. If you add the ice cream after the soda, most of those soda bubbles have already formed and popped before the thickening agents can get to work.