The Best Code is No Code At All

It seems that it would make sense to move toward higher-level languages that do more with less. I’m more a sysadmin than developer so I gravitate more to Ruby/Perl/Python sorts of languages than C#/Java/C++/C languages, but I treat the former as first-class languages rather than a more powerful shell. Despite whatever performance hit you might take with Perl (and compared to Java, it’s a wash), you get a more expressive language per line of code, even without resorting to baffling idioms, side-effects, and mind-bendingly terse code. Remember, C was designed for systems programming, not application development and that’s a disadvantage shared by all languages that inherit from it.

You’re wasting your time second-guessing a compiler. If performance matters then you need to profile your code and hit up Knuth or Sedgewick for a better algorithm or design.

I don’t do C# or .NET [1] or so I have nothing to add to the ‘which code fragment is better’ argument other than to ask what condition the developer really means to test for, and what the language reference manual says about the different tests suggested. I’d worry about a language that doesn’t optimize “” into a constant, though if “” is created and destroyed in each iteration of a loop, is it affecting performance enough to care about? How would you know?

Then again, I’m a sysadmin. My job is cleaning up after developers; rarely do they ask me for advice. :slight_smile:

[1] Frankly, if all my Windows servers disappeared tomorrow I’d take that as evidence of a benevolent, omnipotent deity.