4 ms·
Evidence in a micro benchmark of a single page of code. The focus on performance here ignores the fact that most programs are large systems of many things that
by st3fan 4y ago
Evidence in a micro benchmark of a single page of code.
The focus on performance here ignores the fact that most programs are large systems of many things that interact with each other. That is where good design and abstractions and “clean code” can really help.
Like all things it is about finding a balance and applying the right techniques to the right parts of a larger system.
- TheFattestNinja 4y agoTrue, the example is simplistic, but that's just to make it fit within reasonable exposition. The author has in the past shown (elsewhere) how his techniques can actually make dramatic differences in more concrete examples (he rose to some Internet fame for building a performant shell that could actually handle larger outputs orders of magnitude better than most available alternatives). To me the interesting point is the reminder that there is an innate tension between going fast and being "clean" (i.e. maintanable/understandable). And once you are aware of it you can make your decisions in an informed way. Too often this tension is forgotten/ignored/dogmatically put to the back ("performance doesn't matter over cleanliness" and the likes). Mind you, I'm also of the camp that performance is very secondary to cleanliness in modern enterprises, but I appreciate a reminder of just how much we are sacrificing on this altar.
- cma 4y agoIt was Windows Terminal he wrote something faster than. Windows terminal was doing a whole GPU draw call per character (at 2x standard terminal height, 160x25, it was as many draw calls as a AAA game).
- gongle 4y agoNo matter what design choices you argue for there are always ways to be an idiot about the implementation
- vkou 4y agoWhich is an excellent argument for why the WT team should have done some benchmarking, identified that they have a really dumb O(M*N) bottleneck in a critical part of their application (their rendering code), and optimized it. It is not an excellent argument for why 'clean code' is not a better fit for the other 99% of their codebase.
- gjadi 4y agoI'd say that it really depends on what the code needs to do. For example, if the code is to be distributed and extended as a third-party library, then the class hierarchy is probably a better fit to allow extensibility. But if the purpose of the API is to compute the area of given shapes (as in the example), then it makes sense to make it efficient and there is no use to provide extensibility to the outside world. The advocates of "clean code" that Casey mentions will go for extensibility no matter the use. I find it very interesting to have numbers to weight what you are leaving when you go the extensibility route instead of the non-pessimistic route.
- st3fan 4y ago> The advocates of "clean code" that Casey mentions will go for extensibility no matter the use. Unfortunately this is just some catchy stereotyping that probably doesn't match reality.
- gjadi 4y agoI don't know. Before reading Casey, I'd say most, if not all, of my APIs would look like the "clean code" style. The process was "think about the model, design a class hierarchy that fits with the model, add the operations". Even if I don't think about extensibility, that's how I thought my code. Why? Because when I think about performance, I used to think about algorithms and I/O optimizations (for example batching). Now I'll look into this data-oriented programming-thing and see how that applies to my platform (embedded Java) :D
- jstimpfle 4y agoThe code examples with the abstract / virtual methods for the most straightforward concepts are a clown show. Not cleanliness but madness.
- loup-vaillant 4y agoThat's what you get with SOLID. Madness.
- deleted 4y ago