When Polymorphism Fails — cover art: a small storybook elf in a green hood sits cross-legged on a worn oak table, surrounded by a half-circle of small carved wooden monster-figurines (orc, troll, dragon, elf-maiden, goblin), pointing accusingly at one with a scowl. 👍

2004 · Drunken Blog Rants · Rant

“Polymorphism only makes sense when the polymorphic behavior is really a behavior of the target. When it's the behavior of the observer, you need runtime typing.”
— From When Polymorphism Fails, August 2004
Read the essay

© 2004 Steve Yegge. Originally published at Drunken Blog Rants.

AI Notes

One of the earliest Drunken Blog Rants, from August 2004, when the column's audience was still mostly Amazon coworkers: it ribs a colleague by name, hands the reader a real Amazon interview question (the "eval" problem, brought in by Ron Braunstein) to try at home, and confesses to a third glass of wine right before the thesis lands. The hypothetical also has a hidden autobiography. Where the essay mentions online games that let players write their own code, the link points to cabochon.com — Steve's own company, whose game Wyvern had been running user-contributed monsters for years. The elf scenario came out of a system he actually operated, which is why he digs in so hard against the Fowler-approved answer he quotes at the top.

As a design essay it's cheerfully ragged. The code samples read like they were transcribed mid-pour; the Ruby thread-safety worry ends with Steve admitting he can't read the Japanese spec well enough to check; and the classic OO escape hatch, the Visitor pattern, never gets named even though his crack about creating "150 helper classes" walks right past it. He also treats the dilemma as unmapped territory when Philip Wadler had dubbed it the expression problem back in 1998, and Lisp's multimethods had been dispatching on the observer's terms for a decade before that. The complaint holds up anyway, and the detours reward the trip: a swipe at OCaml for shipping without a polymorphic print statement, objects that respond to delegation by goofing off watching Strong Bad clips, and a sign-off that calibrates blog length in glasses of wine — the exact finding is his to deliver.

Related listings