Disclaimer: I have written one Java program in my career, (although I have read quite a few).

Take this personal mistake that I made in a critical data path as an example:
for (int i<0; i< array.size(); i++) { String result = "PR-" + array[i] + "-RD"; file.write(result); }

I can safely say I wouldn't have made the i < array.size() error. I've seen this enough in various other languages to know to hoist the function call out of the loop construct.

On the other hand, I'm pretty aghast at the way Java forces you to deal with string concatenation. There is always a trade-off between language purity and getting the job done. The Proper Way to do in Java is one that you are unlikely to determine all by yourself, even if you saw it in someone else's code.

It seems to me that the Java language designers went too far down the purity route, rather than having the compiler do the right thing for you. That's not the best use of costly human time. Make the compiler do the grunt work. Even in C++, an awful lot of effort has gone into building compilers that optimise away intermediate copy constructors and what not. I am surprised that Java compilers are not up to the level that C++ compilers were any number of years ago.

--
g r i n d e r

In reply to Re: A peek at the other side or, Poof and He's Gone! by grinder
in thread A peek at the other side or, Poof and He's Gone! by mr.nick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.