3 ms·
Simplicity should be sacrificed for performance. It doesn’t always have to be that way though. Several important classes of optimization lend themselves to sim
by hinkley 9y ago
Simplicity should be sacrificed for performance.
It doesn’t always have to be that way though. Several important classes of optimization lend themselves to simplifying code.
For example, code that effectively makes the same decision three times is both slow and obscures the intent of the code.
And there are ways to compartmentalize optimizations so that people working in the general vicinity don’t have to bother with the ‘clever’ code on a daily basis.
- jorgeleo 9y agoI don't see how it relates. The idea is if I have to choose between simplicity and performance, I shall choose performance. Your example does not make sense because you are not choosing simplicity over performance because the code was already performing slow. Compartmentalizing the code to hide the complexity behind a black box does not apply either because you are not making a complex code simpler, the one that has to maintain your black box is still exposed to the "clever" code.
- hinkley 9y agoBy compartmentalizing I mean in the realm of Single Responsibility at the level of a function. A block that scans a table for a match can be moved up and out and then replaced at your leisure with a version that is more sophisticated and faster and the people using it only have to look at it if there’s a bug. They don’t have to look at it then they don’t have to grumble about how it took 10 lines of comments to document four lines of code because you used some uncommonly known property of Logic or Set Theory to eliminate a bunch of duplicate work. And worst case they can revert the changes until they sort it out because it’s just one function with the same interface. (Also, they won’t fight you as much about the initial change because it’s easy to revert and self contained)