Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: So I did "FizzBuzz", in Java! Date: Mon, 18 Jul 2016 17:30:44 -0400 Organization: A noiseless patient Spider Lines: 37 Message-ID: References: <1933e39b-6363-4174-8392-602415a61799@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 18 Jul 2016 21:30:55 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="20070"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+j44zZb+lGm4KN8gI3UXes" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: Cancel-Lock: sha1:MjEgCa75gXbKmTY49ydJDCO5WJo= Xref: csiph.com comp.lang.java.programmer:34960 On 7/18/2016 5:00 PM, Eric Douglas wrote: > On Monday, July 18, 2016 at 2:10:07 PM UTC-4, Eric Sosman wrote: >> 3) This is not the first "efficiency" question you've asked, which >> leads me to fear that you may be well on the way to becoming an addict. >> Stop! Stop now, while you still can! "Efficiency" is a drug as habit- >> forming and as destructive as anything you can find in a darkened back >> alley. If you get hooked, you'll never get clean. Trust me, I know: >> The monkey has ridden my back for half a century despite my strenuous >> efforts to dislodge it. Don't follow my pathway to ruin! > > It depends how big the efficiency problem is and how many places it's used.[...] Right. Which means you must measure *before* fiddling around, most especially before micro-fiddling. - If you don't measure, you don't actually know whether you have a problem. - If you don't measure, you won't know whether any changes you make are helpful or hurtful. - If you decide a `for' loop is more efficient than an IntStream, based on no evidence whatsoever, you're just thrashing around. - Even if you have measurements in hand that demonstrate one is more efficient than the other, bear in mind that the iteration count of O-N-E H-U-N-D-R-E-D (!!!) is so small that any conceivable difference will be noise. - Finally, observe that by transforming a correct program from IntStream to `for' loop you produced an *incorrect* program! Faster, yes (even without measurement I'm confident of that), but incorrect nonetheless. What price "efficiency," hmm? -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM