Re: GOTO vis-a-vis professional vs amateur programmers
- From: "Judson McClendon" <judmc@xxxxxxxxxxxxx>
- Date: Sat, 8 Sep 2007 12:26:31 -0500
"Gordon Rahman" <grahman@xxxxxxxxx> wrote:
"Judson McClendon" <judmc@xxxxxxxxxxxxx> wrote:
Write the code using good programming technique, and you will rarely
need a debugger. Back in the days when structured techniques were new,
I trained dozens of programmers who were used to using GOTO all the
time to write structured, essentially GOTO-less code.
Hello Judson,
Would it help you understanding my point of view if I put it this way?
I believe I understand your point of view, and as I said at the start of this
thread, I am not critical toward casual programmers who use GOTO, or
even toward professional programmers who use GOTO when it can't be
avoided or when GOTO is preferable to alternate clumsy code.
It's not the programming technique. It's the total environment.
The environment is intended to be an enabler, not a crutch so you can
get by with poor programming practices. With good tools, you can get
by with poor skills. With good skills you can get by with poor tools.
But just think how much more effective a programmer can be with both
good tools and good skills! :-) If people are paying us good money to
write programs, then we owe it to them to use all our resources and
skills wisely.
I mean the language you use and the tools (debugger and so on) you can use.
BASIC has a GOTO command. You may use it as you like. But you can't use it as you like.
It's impossible to place a GOTO in a LOOP structure.
It's impossible to program without indented blocks.
It's impossible to omit END IF.
It's impossible to jump out of FUNCTIONS and so on, and so on.
Don't worry. A good programming language looks after a lot of those things. Including GOTO.
As Richard pointed out, the language can protect you only to a certain point.
The programmer must assume responsibility to use the tool (the programming
language) wisely.
I have a program that misses even ON GOTO!
The other thing is: I use BASIC to write a listing and to learn how Windows works.
Sometimes I want to sneak into others their listings. Most of the time they don't like that.
You're welcome to "sneak into" the code on my website, if you want. ;-)
As much as this issue has been hashed and rehashed, it seems some of
you still don't quite grasp the essential point. Maybe we're not expressing
it in terms that are clear to everybody. This is all about probability, and
choosing the wiser approach. Let me give you a physical analogy, which
I believe is pretty faithful to the reality.
Say you have a box of tools. Now, say that one of those tools is a bit
risky to use, such that any time you use it, if you're not *absolutely
precise* in using it, there is a good chance that it will damage what you
are working on. To compound the problem, the nature of this tool
makes it harder to tell when you are being absolutely precise than it is
with the other tools. Your other tools have to be almost negligently used
to cause damage, and it is easier to tell when you are about to cause the
damage. They are safer to use correctly, as has been proven by many
studies of people using these tools, from the most clumsy to the most
expert. These same studies also show that the most skilled tool users,
the ones who do the most and best work with them, rarely or never use
the risky tool.
Now, you are free to ignore the risk and use any of the tools as you
want. You can practice and hone your skill in using the risky tool so
you will be less likely to make a tiny mistake when using it. You can
decide you're simply fond of the risky tool and use it anyway. You can
give any of the excuses people give to rationalize doing what they want
against better judgment. But if you're wise, you will use the safer tools
all the time, except when the risky tool is the only one that will do the
job, or when it will do the job much quicker or easier than the other,
safer tools. Now, the reality is, if you have a very good and complete
set of tools, including the risky tool, the other tools can always do the
job as well, and as easily, as the risky tool, without the risk. Win-Win.
When the programming language provides appropriate well-structured
constructs, there is never a situation when GOTO is the better choice
from a structural standpoint. For the majority of modern higher level
languages, including most modern BASICs, the times when GOTO is
better is very small, unless you happen to write a lot of code in those
narrow niches where language support for better, more structured
constructs is limited; primarily certain types of exception handling.
In an extremely small percentage of code, GOTO can be warranted
to speed execution. I've written this kind of code, and used to be
considered pretty good at it. When I had been programming for less
than a year, I received a commendation for writing some utility math
routines that were several times smaller and faster than the standard
ones used by my organization. But the amount code needing this kind
of optimization is small indeed, and better compiler optimization and
faster CPUs continually make it less important.
--
Judson McClendon judmc@xxxxxxxxxxxxx (remove zero)
Sun Valley Systems http://sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."
.
- Follow-Ups:
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Gordon Rahman
- Re: GOTO vis-a-vis professional vs amateur programmers
- References:
- GOTO vis-a-vis professional vs amateur programmers
- From: Judson McClendon
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Auric__
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Vic Drastik
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Gordon Rahman
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Judson McClendon
- Re: GOTO vis-a-vis professional vs amateur programmers
- From: Gordon Rahman
- GOTO vis-a-vis professional vs amateur programmers
- Prev by Date: Re: GOTO vis-a-vis professional vs amateur programmers
- Next by Date: Re: GOTO vis-a-vis professional vs amateur programmers
- Previous by thread: Re: GOTO vis-a-vis professional vs amateur programmers
- Next by thread: Re: GOTO vis-a-vis professional vs amateur programmers
- Index(es):
Relevant Pages
|