Inheritance was invented as a performance hack Inheritance was invented by the Simula language as a way to support intrusive lists, save memory, and simplify the garbage collector. It's well known that inheritance was invented by Simula. The History of Programming Languages session on Simula tells us the motivations behind that invention. Let's take a look. Simplifying the garbage collector Simula created inheritance instead of using composition because it allowed their garbage collector to be simpler. Simula had a simple reference counting and garbage collection implementation: Unable to find such a [manual memory allocation] scheme providing sufficient programming flexibility, we implemented a reference count scheme, an idea borrowed from Weizenbaum (1962), and also added a "last resort" garbage collector. Using reference counting and garbage collection is fine and good, but their GC was a little too simple: A process could outlive its dynamic parent, i.e., the block instance containing the generating expression which gave rise to the process. As a result the process might access nonexisting data through its formal parameters. The remedy chosen was to forbid all kinds of call by name parameters to processes (including procedures, labels, and switches). The problem is that one can store a pointer to a stack-allocated variable inside of an object ("process", in Simula terminology), then return that object from the scope of that variable, so the stack frame storing the variable is deallocated. That will make later use of that object unsafe: "the process might access nonexisting data". With more sophisticated garbage collectors, such as the ones used in Lisp even at the time, this is not an issue. The simple GC implementation in Simula solved this problem and others by banning passing many things as arguments, including passing functions as arguments. In a sense, they removed the support for first-class functions which existed in ALGOL 60, which Simula was an extensio...
First seen: 2025-05-08 03:08
Last seen: 2025-05-08 12:32