3 ms·
> All abstractions leak. I cannot make an abstraction perform better than what's underneath Performance is not within the scope of abstraction. This is a categ
by naasking 7y ago
> All abstractions leak. I cannot make an abstraction perform better than what's underneath
Performance is not within the scope of abstraction. This is a category error.
Also, your claim is incorrect as a general statement. The type structure of a given program is an abstraction of its value flow, but without that abstraction a compiler would not be able to optimize it nearly as well. A typed program will always be faster than an equivalent untyped program.
Creating an abstraction may also allow you to add a transparent memoization layer, which not only can make your program orders of magnitude faster, it can make previously unsolvable problems solvable (see how PEGs handle left recursion).
- AnimalMuppet 7y ago> > All abstractions leak. I cannot make an abstraction perform better than what's underneath > Performance is not within the scope of abstraction. This is a category error. It's not within the scope of abstraction... until it is. When that beautiful abstraction does exactly what you need, but does it too slowly to be usable in your circumstances, performance is not separable from the abstraction. (I mean, yes, performance is part of the implementation of the abstraction, not the abstraction itself. But the moment I have to care about the implementation of an abstraction rather than the abstraction itself, the abstraction has leaked. Performance is absolutely one of the ways that this can happen.) And, as a concrete example, the STL went to great lengths to specify the performance of their abstractions.
- naasking 7y ago> But the moment I have to care about the implementation of an abstraction rather than the abstraction itself, the abstraction has leaked. No, that's not what leaky abstraction means. If an abstraction specifies its performance properties, but those properties depend on context that isn't captured by or enforced by the abstraction, that's a leak. To use your example of the STL, if you can allocate a fast constant-time abstraction at a misaligned address, thus causing it to violate its own performance specification, that's a leaky abstraction. Having the wrong performance characteristics simply means it's the wrong abstraction, not that the abstraction is leaky.
- AnimalMuppet 7y agoI think you're a bit too narrow in your definition. If an abstraction specifies properties, but I have to care about more than those properties to be able to use the abstraction, then the abstraction leaked. Performance can be one of those things I have to care about.