Algorithm is such a fancy word. The actual math part, on CodePen, isn't all that complicated. We like to calculate the "popularity" of Pen, so we can do things with that information. For example, sort search results by popularity, so the chances of you finding useful things is higher. We calculate the popularity just as you might expect: a combination of things like views, comments, hearts, and age.

One of the obvious places we use this popularity calcuation is on the Popular Pens. We had been keeping an eye on that page for some time, and we weren't all that happy with what was showing up there. Pens weren't rotating in and out of there as regularly as we would have liked. Some really old stuff would resurface more commonly that seemed appropriate. Some Pens that were clearly not very popular at all would somehow end up at #1.

So we fixed it! Or we took a crack at it, anyway. We also split the popularity calculation up. That value is calculated and used differently depending on the page. The Popular Pens page uses a popularity score calculated differently than the popularity score that the Pens on your Profile page uses.

High five to Tim Sabat and Andy Smith for the work on this. The infrastructure behind it is pretty interesting. Perhaps we'll do a podcast on it one of these days.