http://qs321.pair.com?node_id=935673


in reply to Re: logical non-short-circuit operators
in thread logical non-short-circuit operators

I strongly agree.   When I read this code, it is immediately obvious that “the designer’s intent” is that both function calls will be and should always be executed.

Years ago, the manufacturers of a debugging tool would publish in Dr. Dobb’s Journal a short excerpt of “C” code with the challenge to figure out what the code actually did.   My impression was always, “gee, I can’t afford to use a language like that encounter code written like that.”   (Note that I’m not talking about the debugger tool that was being advertised.)   Code has to be clear and obvious above all other things, such that anyone who might be reading the unfamiliar code (perhaps under conditions of pressure and great haste) can instantly and correctly understand it.   The compiler can take care of itself.   (A tiny scrap of code, written by persons unknown, a mere four lines long but buried out of sight, once cost me $10,000 in real money.)

  • Comment on Re^2: logical non-short-circuit operators

Replies are listed 'Best First'.
Re^3: logical non-short-circuit operators
by BrowserUk (Patriarch) on Nov 03, 2011 at 15:08 UTC
    Code has to be clear and obvious above all other things, such that anyone who might be reading the unfamiliar code (perhaps under conditions of pressure and great haste) can instantly and correctly understand it.

    Let' s posit a few equivalent scenarios.

    1. Every legal document has to be clear and obvious so that any newly qualified lawyer that just barely scraped through law school can immediately apply it to every possible situation to which it might be applicable.
    2. Every music score should be so simple and obvious that any school kid with a tin whistle should be able to render it with same fidelity as a full orchestra.
    3. Every engineering blueprint should be so clear and obvious that any half-competent DIY enthusiast with a Swiss Army knife and a Leatherman will be able to produce the component over a weekend.
    4. Every electronics schematic should be so clear and obvious that anyone with a soldering iron can knock one up in a couple of hours.
    5. Every annotation of the Human Genome should be so clear and obvious that any kid with a Junior Chemistry kit can whip themselves up a little brother or sister once they've finished their homework.

    Just because the world and his dog can pick up a copy of "Sams Teach Yourself HTML 4 in 24 Hours" and put together a web page with lurid fonts, pretty pictures, a hit counter and bunch of social site click buttons in a weekend, it doesn't mean that professional programmers should dumb down their code in the vain hope that: anyone who might be reading the unfamiliar code (perhaps under conditions of pressure and great haste) can instantly and correctly understand it."

    Programming is one of the most complex endeavours man undertakes. Doing it well requires knowledge of such a range of diverse and ever changing algorithms and disciplines; and it can be applied to a huge range of problems. The very expectation that even highly competent and experienced programmers coming from different disciplines or backgrounds should be able to instantly and correctly understand another's programs is ludicrous.

    It is like suggesting that an aroma therapist should be able to take over from a heart specialist or a brain surgeon at a moments notice.

    In no other professional discipline do its exponents make such claims. When will programmers stop devaluing the skill, expertise and learning required to perform their trade by making such puerile and facile claims?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.