[Coco] GOTO and code maintainability
aawolfe at gmail.com
Tue Sep 8 09:36:24 EDT 2009
On Tue, Sep 8, 2009 at 8:40 AM, Rogelio Perea<os9dude at gmail.com> wrote:
> On Mon, Sep 7, 2009 at 9:26 AM, Aaron Banerjee <spam_proof at verizon.net>wrote:
>> All of us have at least at one point in time either used, or tried to
>> figure out code containing GOTO statements. In a recent programming
>> environment I was in, GOTO (or it's equivalent in whatever language we
>> happened to be programming) was expressly forbidden -- no exceptions no
>> matter what.
>> Just to be an irritant, I chucked a single GOTO (to make a polling loop) in
>> a relatively simple program, which totally confused my colleagues.
>> Given that it isn't abused, I don't see why GOTO makes code any less
>> maintainable than other obviscation techniques, such as polymorphism (which,
>> while useful, if abused can lead to very multiple inheritance or
>> exception-based program control. At least GOTO tells you where it is
>> Has anyone else run into this type of "GOTO intolerance" while programming?
>> - Aaron
> To be honest, I never understood the backlash GOTO suffered from structured
> language evangelists, I felt it was to be taken as the one and only
> source/cause of spaghetti code; that was the rhetoric from the uprising
> Pascal and C community back in college (mid 80's for me)... my generation
> had been brought up with TRS-80 Basic and 6800 ML assembly and that made us
> all of the sudden the old guys who knew nothin' about programmin'.
> Same could have been said about the IF THEN ELSE construct with its implied
> GOTOs, yet no one raised a ruckus over that... GOTO was the four letter word
> to be wary about. Sigh...
> -- Rogelio
This thread has been interesting and lead me to read a few papers from
the 70s/early 80s discussing GOTO. In hindsight, it seems the
movement against GOTO started with some very intelligent folks talking
rationally about the merits of structured programming and somehow
became distorted by less smart people into part of a general disdain
for "amateur" or hobby programmers. Maybe the established
professional programmers and CS professors felt threatened by the
increasing availability of computers to average folks. BASIC is
(mostly) unusable without GOTOs, BASIC was used by many of these new
hobbyists, and the two become associated with spaghetti code and
I'm sure people did pick up many bad practices by learning BASIC
mostly on their own (I know I did! :), and professors went from
instructing people with no prior experience to these new students who
thought they knew much more than they did (again, I sure did). It
probably irked the profs to see these kids using BASIC to explore what
was previously their exclusive domain. Telling these kids that a
fundamental part of their prior experience was forbidden in "real"
computer science had to be satisfying, even for those who knew this
was a bit inaccurate.
I think there is much truth behind GOTO being "considered harmful" in
many situations, but this truth is not fully understood by most of the
people who decry it's use. Fear of GOTO has become wrapped up with
general dislike of BASIC and all things "amateur". Even today, Visual
Basic is looked at with contempt by many (most?) professionals,
despite being quite a capable language (and really nothing like
BASIC). Heck, I leave VB and VBA off my resume despite many years of
experience with them.
I'm sure amateurs are doing some horrible things in VB even as I type
this. On the other hand, I've seen many awful things done in Java, C#,
etc too (the daily WTF http://thedailywtf.com/ is very funny
reading). Something about the label "BASIC" brings out a tradition of
dislike that seems to have been taught even to young programmers who
never used the 8 bit BASICs that I grew up with.
Ok.. ramble done, GOTO work.
More information about the Coco