4 ms·
I regularly write code in this optimized form and regularly get code review suggestions to change the code to make it sequential "for readability". Yes, it's ha
by davidmurdoch 5y ago
I regularly write code in this optimized form and regularly get code review suggestions to change the code to make it sequential "for readability". Yes, it's harder to read, but it cuts runtime in half or more at the most performance critical part of the application. I think we developers too often try to cater to an imaginary lowest common denominator developer. Sometimes it is okay if code takes a little extra effort to read.
- happytoexplain 5y agoI agree - however, I don't think the developers we are imagining are imaginary. They exist and are common, but we shouldn't be catering to them as much as we sometimes do. Maybe that means leaning away from pragmatism and toward purism, but my hope is that software generally moves that way over time. Edit: Not "moves that way" as in becomes completely purist, just that I hope it lands a little closer to that side of the spectrum in the future.
- hinkley 5y agoCoding for aesthetics is purism. Coding for human cognition/DevEx is pragmatism. They looks similar to an outsider, but the hills they choose for dying can be fairly different.
- lowbloodsugar 5y agoHorses for courses. We have to admit that it takes a team with more skill to build a nuclear submarine than it does to inflate a dinghy, but conversely, no point paying nuclear engineers for your dinghy company. If you are building dinghies, or indeed mass producing dinghies for small clients, sure, pragmatism is not using complex async code. If you are building a nuclear submarine, the team better have a real good idea of how these parallel systems interact, don't deadlock the cooling system, and pragmatism might be "who knows TLA+?".
- darksaints 5y agoThat can cut both ways. Sometimes optimizations reduce legibility even for advanced programmers, and often for very marginal improvements in performance...or no improvement in performance at all because they're not on the critical path. Sometimes it's okay to make code slower but more obvious as to what it is doing.
- hinkley 5y agoVariable hoisting can make a loop faster and the intentions clearer. As long as you don’t hoist the variable entirely off the page, that is. Declaring at the top of a large scope is confusing. I think people got that from older versions of C as I recall. It’s worse than doing nothing.
- hinkley 5y agoThe smaller the function with the perf tweaks, the less pushback you tend to get in reviews. Near as I can surmise, there’s a threshold below which people feel comfortable refactoring code they don’t like the looks of, but the fact of that comfort discourages them from actually doing it. You do have to watch out for features being added. Plenty of people don’t understand rewording these three lines results in a 10% response time increase.