Story Details

  • Inheritance was invented as a performance hack (2021)

    Posted: 2025-05-06 10:59:18

    The blog post argues that inheritance in object-oriented programming wasn't initially conceived as a way to model "is-a" relationships, but rather as a performance optimization to avoid code duplication in early Simula simulations. Limited memory and processing power necessitated a mechanism to share code between similar objects, like different types of ships in a harbor simulation. Inheritance efficiently achieved this by allowing new object types (subclasses) to inherit and extend the data and behavior of existing ones (superclasses), rather than replicating common code. This perspective challenges the common understanding of inheritance's primary purpose and suggests its later association with subtype polymorphism was a subsequent development.

    Summary of Comments ( 174 )
    https://news.ycombinator.com/item?id=43903705

    Hacker News users discussed the claim that inheritance was created as a performance optimization. Several commenters pushed back, arguing that Simula introduced inheritance for code organization and modularity, not performance. They pointed to the lack of evidence supporting the performance hack theory and the historical context of Simula's development, which focused on simulation and required ways to represent complex systems. Some acknowledged that inheritance could offer performance benefits in specific scenarios (like avoiding virtual function calls), but that this was not the primary motivation for its invention. Others questioned the article's premise entirely and debated the true meaning of "performance hack" in this context. A few users found the article thought-provoking, even if they disagreed with its central thesis.