Timeline for Clean readable code vs fast hard to read code. When to cross the line?
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:40 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| Jul 11, 2011 at 21:56 | history | edited | Mike Dunlavey | CC BY-SA 3.0 |
added 614 characters in body
|
| Jul 8, 2011 at 20:31 | comment | added | Mike Dunlavey | @Marc: Agreed. I'm talking about application code. In library code, it may be necessary to use unusual methods to get speed. | |
| Jul 7, 2011 at 15:31 | comment | added | Rex Kerr | @Mike Dunlavey - I guess we see different things. In any case, the dichotomy is real in some cases, and I've given a specific example. | |
| Jul 7, 2011 at 2:05 | comment | added | Mike Dunlavey | @Rex: I relegate algorithm decisions as low as I can on the totem pole. I've got user-visible features to implement, and requirements are going to change. Making code robust and easy to add to and change is my priority. Oddly enough, simple is also usually fast. If there's a performance problem, I find it, fix it, and forget about it. I see so many performance problems caused by hairy data structures and algorithms put in, for what purpose? Performance! | |
| Jul 6, 2011 at 22:40 | comment | added | Rex Kerr | I have to agree with the false dichotomy crowd. For example, do you implement dual-pivot quicksort or selection sort? The former is way less clean--even if you code it as cleanly as possible--than selection sort, but is much, much faster for large sorting jobs. | |
| Jul 5, 2011 at 13:45 | comment | added | Mike Dunlavey | @jhocking: I know what you mean. Perhaps the answer should be more nuanced. Here's an example of what I mean. Certainly when you get down to shaving cycles that's one end of the spectrum. In the kind of mega-line apps I'm familiar with, it's another story entirely. | |
| Jul 5, 2011 at 13:08 | comment | added | jhocking | I disagree that it's a false dichotomy. Because I do a lot of graphics work the most obvious example to me is in tight graphics loops: I don't know how often this is still done, but it used to be common for game engines written in C to use Assembly for core rendering loops in order to squeeze out every last drop of speed. That also makes me think of situations where you program in Python but use modules written in C++. "Hard to read" is always relative; any time you drop to a lower-level language for speed, that code is harder to read than the rest. | |
| Jul 5, 2011 at 7:33 | comment | added | Loki Astari | We have all found times that we need to try and make the code go faster. But after experimentation with the profiler to find the best solution (were the code gets ugly) this does not mean the code needs to stay ugly. It is a matter of finding the best solution which may not at first seem obvious but once found can usually be coded cleanly. Thus I believe it is a false dichotomy and just an excuse not to tidy your room after you have had the fun with your toys. I say suck it up and tidy your room. | |
| Jul 5, 2011 at 7:30 | comment | added | user1249 | Marc, you can link to answers in comments with the "link" URL. programmers.stackexchange.com/questions/89620/… | |
| Jul 5, 2011 at 6:18 | comment | added | Marc Gravell | I do not agree it is a false dichotomy; IMO there are scenarios especially in library code (not so much in application code) where the split is very real. See my answer for more. | |
| Jul 5, 2011 at 6:01 | comment | added | edA-qa mort-ora-y | I agree. Indeed fast code that is not clean is going to get slower eventually as you can't properly modify it. | |
| Jul 5, 2011 at 2:22 | history | answered | Mike Dunlavey | CC BY-SA 3.0 |