<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx</link><description>The first in an ongoing series (in other words, as soon as I figure out what more rules are, I&amp;#8217;ll write more articles in the series). This post was inspired by a comment in Raymond&amp;#8217;s blog where a person asked &amp;#8220;You mean you think I&amp;#8217;m</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#108720</link><pubDate>Tue, 06 Apr 2004 23:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:108720</guid><dc:creator>Jerry Pisk</dc:creator><description>That's all nice and good if you work as contractor - you get paid by the hour. I personally think that simple, readable (and therefore managable and less prone to bugs) code is more important than code that saves 20 bytes of memory and runs two milliseconds faster. Hardware is cheap compared to programmers, even those in India. But if your team writes code that's full of bugs because they're trying to play tricks with the compiler to make the code run a little bit faster and use a little less memory and then spends weeks trying to find those buggers you're just wasting money and time.&lt;br&gt;&lt;br&gt;Remember people who were smart and used the top bit in memory pointers to hold their flags? That saved some memory but created code that needs to be completely re-written (to run in an environment that ca address more than 2GB of RAM). And there's tons of other examples...</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#108794</link><pubDate>Wed, 07 Apr 2004 02:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:108794</guid><dc:creator>Mike Kozlowski</dc:creator><description>The problem with &amp;quot;knowing&amp;quot; what the assembly looks like is that your knowledge can get out of date.&lt;br&gt;&lt;br&gt;Lots of Java programmers &amp;quot;know&amp;quot; that they shouldn't do String concatenation by writing x = a + b + c + d + e;, for instance -- that allocates all sorts of extra strings (as in your example above) and is just terribly inefficient.&lt;br&gt;&lt;br&gt;Only, it doesn't:  The compiler actually translates those concatenation into StringBuffer calls invisibly, and it all works just performantly delicious.&lt;br&gt;&lt;br&gt;So for the past umpty-ump years, I've been dealing with code that's needlessly full of StringBuffer.append() operations, when the programmers could have used simple straightforward concatenation, because they &amp;quot;knew&amp;quot; the assembly that was generated, based on their experience with, I dunno, Java 1.1 or something.&lt;br&gt;</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#108818</link><pubDate>Wed, 07 Apr 2004 03:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:108818</guid><dc:creator>Larry Osterman</dc:creator><description>Jerry,&lt;br&gt;  I'd almost want to agree with you.  But I can't think of the number of times that I've been called in to debug someone elses performance problem because they didn't understand why their programming practices generated bad code.  STL generates pretty good code (especially in VC.Net) but you still need to know what's going on under the covers.&lt;br&gt;&lt;br&gt;It's only tricks with the compiler if you're being tricky using the compiler - and I include using templates or operator overloads as being tricky (more on that at a later date)  :)&lt;br&gt;&lt;br&gt;&lt;br&gt;Mike, your point is valid, and it works IFF you have runtime support underneath.  You will note that I didn't comment on the behavior of either managed code or Java, because there are other tricks that happen with those.  The examples I used were all built with VC.NET 2K3, using the STL libraries that come with the compiler (I built a bunch of toy apps to verify the stuff I wrote above, just to make sure it still happened with the current compiler). </description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#108904</link><pubDate>Wed, 07 Apr 2004 07:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:108904</guid><dc:creator>Pontus</dc:creator><description>I kind of agree with Mike, except I think people should avoid C and C++ as much as possible. A very high percentage of those who write code are frankly bunglers (at least when it comes to handling pointers and memory), and _everybody_ makes mistakes. &lt;br&gt;&lt;br&gt;Languages like C#, Java and Python allows us to write code with less faults (and as &amp;quot;someone else&amp;quot; deals with most of the hard and boring stuff, the programs are often faster than they would've been had we coded them ourselves).  &lt;br&gt;&lt;br&gt;Those languages, I could probably follow, but my fianc&amp;#233; could not, and she's still a competent coder in those languages, but then, we regulary use languages like Scheme, SML and Prolog, and those would probably be a hard to follow for me.&lt;br&gt;</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#109054</link><pubDate>Wed, 07 Apr 2004 15:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:109054</guid><dc:creator>Jerry Pisk</dc:creator><description>Larry, if somebody doesn't understand that their innocent line of code is going to create three unnecessary objects then the problem isn't knowing what assembly code gets generated. It's not know how the language you use works. If you knew C++ and how it works with objects you'd know when extra objects are created, without knowing what the actual assembly code is. I think you wanted to say - do not write code unless you know what you're doing. Unfortunatelly not many people do...&lt;br&gt;&lt;br&gt;And I agree that operator overloads are playing tricks, most of the time they make the code very difficult to understand (and therefore maintain).</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#109230</link><pubDate>Wed, 07 Apr 2004 19:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:109230</guid><dc:creator>bg</dc:creator><description>whats the best way to start learning assembly language - books? can you recommend any.&lt;br&gt;&lt;br&gt;ta&lt;br&gt;&lt;br&gt;bg</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#109318</link><pubDate>Wed, 07 Apr 2004 21:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:109318</guid><dc:creator>Larry Osterman</dc:creator><description>An interesting question bg.  I'm actually not sure I know of any that are still in print, but the good news is that I don't think it really matters that much.&lt;br&gt;&lt;br&gt;Jerry's comment above is actually spot-on.  It's not so much the actual instructions (although they DO matter at some point), it's what code is being generated.&lt;br&gt;&lt;br&gt;One thing that I might suggest doing is to use the compiler to generate a .COD file of your source code, then look up the instructions in the Intel processor reference (&lt;a target="_new" href="http://www.intel.com/design/pentium4/manuals/253665.htm"&gt;http://www.intel.com/design/pentium4/manuals/253665.htm&lt;/a&gt;).&lt;br&gt;&lt;br&gt;The bottom line is that I'm not sure that it's necessary to know how to PROGRAM in assembly language any more (and I could put forward a very strong argument that it's a bad idea to program in assembly language at this point), but it IS important that you know how to READ assembly language.&lt;br&gt;</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#109408</link><pubDate>Thu, 08 Apr 2004 01:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:109408</guid><dc:creator>josh</dc:creator><description>The problem with saying that hardware is cheap compared to programmers is that hardware costs scale linearly with your user base, while programmer costs don't.  If you've got a sufficiently large user base then you'd have to have some pretty expensive programmers for this to be true.</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#113633</link><pubDate>Thu, 15 Apr 2004 04:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:113633</guid><dc:creator>Michael Grier</dc:creator><description>I still claim that this comes down to two kinds of programmers.  &amp;quot;Systems programmers&amp;quot; who have to know what the heck they're doing and &amp;quot;applications programmers&amp;quot;.&lt;br&gt;&lt;br&gt;&amp;quot;Applications programmers&amp;quot; are the ones with the massive application backlog and need to work through it.  Frankly they don't have a real quality or performance problem for the most part because the ones who have a clue leave the heavy lifting to the &amp;quot;systems programmers&amp;quot; who are writing things like Exchange and SQL Server.&lt;br&gt;&lt;br&gt;&amp;quot;Systems programmers&amp;quot; are building the components that everyone else leverages and they can't afford to play fast and loose.&lt;br&gt;&lt;br&gt;If the top-level application chooses to write their code more quickly and sloppily and generates 20,000 extra copies of strings but the job still gets done in time, that's great.&lt;br&gt;&lt;br&gt;If the component provider writes their code quickly and sloppily and generates 20,000 extra copies of strings, this is irresponsible and hopefully they will not remain being a shared component provider for long.&lt;br&gt;&lt;br&gt;Shared component providers also have a massive backlog, but the absolute last thing in the world that we need for shared component providers is the ability for them to turn out more shared components more quickly.  Quality stinks and it's not about buffer overruns and leak management - anyone who has problems designing for and addressing these issues isn't qualified to write a shared component in the first place.&lt;br&gt;</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#118785</link><pubDate>Fri, 23 Apr 2004 08:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:118785</guid><dc:creator>Hrvoje Zlatar</dc:creator><description>Why did you make the rule exclusive for assembly language? I would extend it to: Every engineer should understand at least the first layer below the one he's using. For example .NET programmers should understand the internals of CLR.&lt;br&gt;I dare to say that the quality of an engineer may be measured by the number of layers below the one he's working in, he trully understands.</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#119762</link><pubDate>Sun, 25 Apr 2004 11:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:119762</guid><dc:creator>Alex Blewitt</dc:creator><description>The point re replacing a+b+c with stringbuffer is only valid in a single expression. If you are using (for example) a loop, then the compiler will *not* generate a stringbuffer for concatenation. Even different expressions using the same string aren't guaranteed to use an SB.&lt;br&gt;&lt;br&gt;What really gets on my tits is people who are using some kind of output stream (e.g. to an ServletResponse's writer) and do:&lt;br&gt;&lt;br&gt;write(a+b+c); // or println(a+b+c)&lt;br&gt;&lt;br&gt;when you can get concatenation for free using&lt;br&gt;&lt;br&gt;write(a);&lt;br&gt;write(b);&lt;br&gt;write(c);&lt;br&gt;</description></item><item><title>You've got the rule backwards - as per your example...</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#119891</link><pubDate>Sun, 25 Apr 2004 18:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:119891</guid><dc:creator>Pat Niemeyer</dc:creator><description>Your example serves to demonstrate that developers should, under normal circumstances, *not* care about low level code or performance issues... They should just do the &amp;quot;right thing&amp;quot; where that is usually the simplest and most staightforward thing.  If developers had followed this rule in Java all along then they woudln't have been bitten by all these stupid optimization rules that ended up being anti-optimizations when the VMs got smarter.&lt;br&gt;&lt;br&gt;Trust the compiler people... trust the VM people and then when your code is working trust the profilers to tell you what is actually going on.  People's intuition about performance issues is wrong more often thant it's right.  You don't know anything unless you profile it - zip, nada, nothing.  You may think you're a hotshot Java programmer (we all do) but you're wrong most of what you think about optimization.  That's the real rule.&lt;br&gt;&lt;br&gt;Pat Niemeyer&lt;br&gt;Author of Learning Java, O'Reilly &amp;amp; Associates</description></item><item><title>re: What's wrong with this code?</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#122045</link><pubDate>Wed, 28 Apr 2004 17:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:122045</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description /></item><item><title>Beating the </title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#135820</link><pubDate>Thu, 20 May 2004 16:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:135820</guid><dc:creator>From Over the Long Hill</dc:creator><description>Beating the </description></item><item><title>Larry's rules of software engineering part 1, redux</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#154038</link><pubDate>Sat, 12 Jun 2004 08:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:154038</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description /></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#206187</link><pubDate>Mon, 02 Aug 2004 21:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206187</guid><dc:creator>Eric Newton</dc:creator><description>Pat Neimeyer: perhaps you've just proven Larrys point even better than he thought.  You're stressing the importance of understanding optimizations, which is conceptually similar to understanding the assembly language (which itself is conceptually saying &amp;quot;Understand how your code works&amp;quot;)&lt;br&gt;&lt;br&gt;So many times I see code written without regard to &amp;quot;how it works&amp;quot; or even &amp;quot;how does this get optimized.&amp;quot;  To be honest, I see a lot of cut and paste, which is a prime reason why samples should illustrate good practices.</description></item><item><title>re: Larry's rules of software engineering, part 1:  Every software engineer should know roughly what assembly language their code generates.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#207600</link><pubDate>Wed, 04 Aug 2004 03:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207600</guid><dc:creator>Norman Diamond</dc:creator><description>In the base note:&lt;br&gt;&lt;br&gt;&amp;gt; foo = bar + baz + “abc”;&lt;br&gt;[...]&lt;br&gt;&amp;gt; The second is one that’s used to hold the&lt;br&gt;&amp;gt; intermediate result of baz + “abc” which&lt;br&gt;&amp;gt; is then added to bar to get the resulting&lt;br&gt;&amp;gt; foo.&lt;br&gt;&lt;br&gt;OK, string concatenation is transitive, and a compiler might make use of this knowledge in performing some optimization.  But I don't think a programmer should depend on observing that one version of some optimizing compiler used some trick once on one version of the programmer's work.  One maintenance programmer later, the results might be different.&lt;br&gt;&lt;br&gt;In this example, the programmer should start by assuming that bar + baz will generate a temporary, and the temporary &amp;quot;should&amp;quot; reuse itself in adding &amp;quot;abc&amp;quot; to the result.  If the generated code is worse than this, complain to the makers of the compiler or the component, AND if performance is bad then temporarily find a workaround.  If the generated code is better than this, be happy but do not depend on it.&lt;br&gt;&lt;br&gt;(By the way, if these were numbers instead of strings, and subtraction operators instead of addition, I hope your compiler gets the sequence of operations correct.)</description></item><item><title>Hiding Complexity</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#273162</link><pubDate>Wed, 01 Dec 2004 21:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:273162</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description /></item><item><title>Another year, another post</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#552076</link><pubDate>Wed, 15 Mar 2006 20:21:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:552076</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description>Well, this year I didn't miss the anniversary of my first blog post.&lt;br&gt;I still can't quite believe it's...</description></item><item><title>Software Information &amp;raquo; Larry Osterman&amp;#8217;s WebLog : Larry&amp;#8217;s rules of software engineering part 1 &amp;#8230;</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#7197949</link><pubDate>Tue, 22 Jan 2008 15:32:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7197949</guid><dc:creator>Software Information » Larry Osterman’s WebLog : Larry’s rules of software engineering part 1 …</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://softwareinformation.247blogging.info/larry-ostermans-weblog-larrys-rules-of-software-engineering-part-1/"&gt;http://softwareinformation.247blogging.info/larry-ostermans-weblog-larrys-rules-of-software-engineering-part-1/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Generate Assembly From C++ Code in Visual Studio | Code Gem</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#8975435</link><pubDate>Fri, 03 Oct 2008 15:12:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8975435</guid><dc:creator>Generate Assembly From C++ Code in Visual Studio | Code Gem</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://codegem.org/2008/10/generate-assembly-from-c-code-in-visual-studio"&gt;http://codegem.org/2008/10/generate-assembly-from-c-code-in-visual-studio&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Larry Osterman s WebLog Larry s rules of software engineering part 1 | debt consolidator</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#9787871</link><pubDate>Fri, 19 Jun 2009 17:16:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9787871</guid><dc:creator> Larry Osterman s WebLog Larry s rules of software engineering part 1 | debt consolidator</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://mydebtconsolidator.info/story.php?id=15140"&gt;http://mydebtconsolidator.info/story.php?id=15140&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Larry Osterman s WebLog Larry s rules of software engineering part 1 | debt solutions</title><link>http://blogs.msdn.com/larryosterman/archive/2004/04/06/108686.aspx#9791450</link><pubDate>Fri, 19 Jun 2009 21:03:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9791450</guid><dc:creator> Larry Osterman s WebLog Larry s rules of software engineering part 1 | debt solutions</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://debtsolutionsnow.info/story.php?id=11389"&gt;http://debtsolutionsnow.info/story.php?id=11389&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>