--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsma...@googlegroups.com.
To post to this group, send email to software_cr...@googlegroups.com.
Visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Am I telling my students the right thing?
Just yesterday I was doing a code-read-through with one of my students. When we were done, I reworked one of her methods to show how code readability could be improved. She was very concerned about sacrificing efficiency at the expense of writing readable code. When I was done tweaking her method, ironically, the code was more efficient than her original code.
I do realize that extremely optimized code is impossible to read. At a Splash 2011 keynote, Markus Püschel described how they do automatic performance programming. Their goal is to optimize C libraries to the specific CPU chipset, level 1, level 2 caches. Their search space includes how much loop unrolling to do, how big to segment arrays, and any other compiler trick they can think of. Their software will explore this search space for each chipset. A small change in the L2 cache might have impacts on their tuned code. Here was my take-a-way: the highly optimized machine generated code (number in millions of lines of code) is completely unreadable. I assume that the code they use to run their machine learning and heuristics is readable to their programers, while what they produce is only readable to the machine, and that doesn't matter, because no user of it will ever read it.
I do agree that the inner loop of a highly used function should be highly optimized, however, I'd hope we could make that code readable too.
I'm probably preaching to the choir, but if you have any advice on how to convey the message differently, I'd love to hear it. If you disagree with me, help me understand your perspective.
Am I telling my students the right thing?
The code you write is not the code that runs, and can constrain the shape of the code that runs.
Many people are doiing efficiency by old wives' tales. They remember things that used to be true for a given language on a given compiler with a given optimization setting on a certain operating system on a given chipset.
Think about the code generators, the optimizers, the jitter, the microcode, the parralel pipelines, etc. This really isn't 1978 anymore. The correlation between what you write and what it runs is rather loose.
What if a chip version change were to change the heuristics, so you have pessimized the program with your hand-crafted loop-unrolled, extra-primitiveized code? What if you've had a case of "optimizer feature envy" and made it impossible for the runtime to arrange locality of reference so it can make good use of L1 cache? Cache misses are a huge performance spoiler, but indirect function calls within cache are no big deal.
A lot of people are terrified of stack frames and variables that resolve to registers.
We fear too many of the wrong things.
The fact is that other than good algorithms and clean code, there is less and less we can reliably say about how our code will perform.
Of course, waiting on networks or databases will have more impact than microefficiencies.
That's just what I have come to understand. My friends who wrote games with high refresh rates tell me that they still had a lot of profiling and magic rework to get their games to be smooth and responsive.
Tim
--
On Mar 28, 2013 9:51 PM, "Todd Sedano" <todd....@sv.cmu.edu> wrote:
Am I telling my students the right thing?In my "craft of software development" course, I've noticed two competing philosophies. Several of my students believe that efficiency is the most important aspect of code, where as, I believe that code readability is the most important aspect of code.
SNIP
I'm probably preaching to the choir, but if you have any advice on how to convey the message differently, I'd love to hear it. If you disagree with me, help me understand your perspective.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsmanship+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsma...@googlegroups.com.
To post to this group, send email to software_cr...@googlegroups.com.
Visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Am I telling my students the right thing?
In my "craft of software development" course, I've noticed two competing philosophies. Several of my students believe that efficiency is the most important aspect of code, where as, I believe that code readability is the most important aspect of code.
As a metaphor, I've been saying that their code should tell a story to the reader. Their job is to rework the code to tell a narrative. Just like story telling has conventions to signal to the reader what his happening and where the story is going, we too can use techniques to inform the reader about what is going on.
I'm probably preaching to the choir, but if you have any advice on how to convey the message differently, I'd love to hear it. If you disagree with me, help me understand your perspective.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsmanship+unsub...@googlegroups.com.
To post to this group, send email to software_cr...@googlegroups.com.
Visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
>"The most important" aspect of code doesn't and can't exist.any recommendations/opinions regarding the viewpoint expressed (for example) in Michael Feathers "readability is the best default for nearly all code" ?Just digging for wisdom.
>"The most important" aspect of code doesn't and can't exist.any recommendations/opinions regarding the viewpoint expressed (for example) in Michael Feathers "readability is the best default for nearly all code" ?
Philip,I think it is at least the best default. I think almost all code can be quite readable and that neither speed nor storage are likely to be negatively impacted by clarity.On Apr 6, 2013, at 10:07 AM, Philip Schwarz <philip.joh...@googlemail.com> wrote:>"The most important" aspect of code doesn't and can't exist.any recommendations/opinions regarding the viewpoint expressed (for example) in Michael Feathers "readability is the best default for nearly all code" ?Just digging for wisdom.
On Apr 6, 2013, at 10:07 AM, Philip Schwarz <philip.joh...@googlemail.com> wrote:
>"The most important" aspect of code doesn't and can't exist.
any recommendations/opinions regarding the viewpoint expressed (for example) in Michael Feathers "readability is the best default for nearly all code" ?
Just digging for wisdom.I think it is at least the best default. I think almost all code can be quite readable and that neither speed nor storage are likely to be negatively impacted by clarity.
--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsma...@googlegroups.com.
I really like your blog post, because it brings to the fore the very nature of what it is that often evades consciousness - Context. I dont like the pithy statement "Premature performance infatuation" because it is not only loaded (infatuation and premature are both context based) but it is also too black and white. I work in a space where if the FIRST thought is not Performance (with a capital P), then it wont matter that it runs or that its even right. A misstep with performance can result in a complete re-write.
As someone who plays a role in hiring for my company, since 2009 when I arrived here in Chicago, I have interviewed more than 30 candidates, and not one has had any deep appreciation of what it means to think about performance. At least 75% of them were agilers. To be sure, they have often been worth their salt from an agile perspective, but theres always been a perceived view that its more important that the code is well factored, and that with all of these good programming/craftsman practices embodied, the code should be fast enough. It rarely ever is.
A good friend of mine works in HFT, but in my 25 years of commercial software development experience I've only come across one other case where performance was the primary criteria. I would suggest that in more than 99% of cases, performance is not the problem, and where it *appears* to be the problem it is usually just a symptom of a different problem - in my experience usually poor design.
This seems to echo the experience of people considerably more experienced and accomplished than I am, so I'm pretty confident in applying it as a rule of thumb, meaning that while I recognise that in rare cases performance is an issue (context is crucial), in the vast majority of cases Beck's Law applies: "A programmer generates complexity in inverse proportion to their ability to cope with it."
Fox
--
I work in high frequency trading and options market making. I am sure we could all learn something from you too. Before I entered this space, with over thirty years of real programming (having written my first programs at eight years old) I had the same experiences or views as your self. Its a demanding environment, thats all I can say. Do we strive for craftsman style code every single day? Yes. Do we have to focus more on performance over all else on an almost daily basis- yes. This isnt an opinion or a subjective experience; its simply a fact I myself have had to come to terms with given my own background in agile development.
I can understand that performance might be a more important aspect in such an environment than elsewhere. But it still won't be above everything else. Especially in trading, making a functional mistake can have a huge financial impact. I would expect readability/maintainability of code to be of very high importance there.You might make some different trade-offs, but I don't think getting it fast before getting it right would be one them.
Going back to my original post, which is in a response to JB, Context was the point, and that while there is a general rule, one needs to know when other forces might take precedence. I haven't stipulated bad or poor design practices to favor performance, or certainly that wasnt my intention. Good practices, good design techniques and principles are not being contested. In my own experience, which is neither luminary status nor accomplished, there have been many more domains than finance that require an appreciation of performance. And in all cases good software design can absolutely be used to drive solutions in those domains, but they still require the designer to be conscious of performance right at the front as a non-functional that impacts the way things must or should be built.
--
I'm really curious about what the performance constraint is: what is the required minimum cycle time from receipt of data input (market event) to data output (presumably an instruction to offer or buy)? What would you consider 'out of spec'?
These four questions are very good JB; I have anecdotes for all to be perfectly honest. Thanks!