Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Control Structures

by willyyam (Priest)
on May 10, 2005 at 13:08 UTC ( [id://455552]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Control Structures
in thread Control Structures

New developers will create bugs regardless of language. It is a gift, without which they would never learn.

Replies are listed 'Best First'.
Re^4: Control Structures
by adrianh (Chancellor) on May 10, 2005 at 17:05 UTC
    New developers will create bugs regardless of language. It is a gift, without which they would never learn.

    To put my devil's advocate hat on for a minute - new developers will create bugs, but language choice can have a huge effect on what kind of bugs.

    For example a newbie developer using a language that naturally supports iteration over containers like Perl's foreach() or Ruby's each() won't hit a whole bunch of off-by-one errors that languages like C curse people with.

    I remember very well an introductory AI programming course that I helped teach a few years back. At the same time as the students were building a GUI driven 3D block world in Pop-11 they were bashing their heads against the wall with segfaults with simple "add up a list of numbers" programs in their C based introductory programming course. No experience before or since has been a better demonstration to me that language choice really matters.

    I just happen to think that trailing if and unless() are not a major cause of problems for novice developers. Certainly not enough of a problem to remove the gain in clarity that they give to experienced developers.

      Yes, do-while is a far worse problem, which is why we changed it to loop-while in Perl 6, and redefined do-block to make it the once-through loop (which conveniently makes it illegal to put a while on it).

      I would also submit that the fallthrough of C switches falls into the category of bugs waiting to happen. Fallthrough is approximately the worst way to implement an "or". So that's not how Perl 6 will do it.

      Another control flow fixup is to unify loop variables with closure parameters, so there's no longer any weird implicit blocking of special-purpose my variables.

      Unifying switches with exception handlers will also prevent a bunch of "roll-your-own" control flow bugs in Perl 6.

      If you count OO dispatch as a form of control flow (and I do), the roll-your-own OO support in Perl 5 also contributed to various forms of bugginess. One might go as far as to say that most of the fixups in Perl 6 consist of choosing better defaults (without making them mandatory).

        I would also submit that the fallthrough of C switches falls into the category of bugs waiting to happen.

        I read somewhere that at least one of the K&R pair is on record as saying that he regretted the fallthrough behaviour of switch, and that it would be one of the things he would do differently if he could. Unfortunatly I cant find a link right now, never did have very good google-fu.

        ---
        $world=~s/war/peace/g

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://455552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-18 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found