On 4/21/2012 12:52 PM, Clark Morris wrote:
On Thu, 19 Apr 2012 04:42:55 +0200, Fritz Wuehler
| ... Practical experience
| beats the college boys every time, especially burnt-out duffers like
| Dijkstra who never sold a line of code and probably never wrote one either.
Based on presentations by Tom Ross at SHARE (IBM COBOL representative)
and my reading of the generated assembler code, I changed my coding
practices to make sure all GO TO statements were eliminated because
they mess up PERFORM optimization.

This is good general programming advice -- not just for COBOL programmers, but for for anyone writing in any modern compiled language.

The behavior of well-defined coding structures like IF/THEN/ELSE, DO, SELECT, CASE, etc. are extremely well understood--both by programmers and by code optimizers no matter which language is being employed. This is one of the chief reasons why structured programs are so much more maintainable than unstructured ones. Every programmer understands a-priori how the control structures work without tedious inspection of the logic to understand the possible paths taken.

Good compiler optimization depends on the compiler understanding what your code is attempting to do and structured, GOTO-less, code is FAR easier to optimize than its GOTO-laden counterparts. A GOTO will often serve as a "monkey wrench" thrown into the "works" of the compiler optimization algorithms. GOTOs are unpredictable; compilers don't know in advance where they will appear in the code; they don't know in advance what the target of the GOTO will be. The optimization algorithms must adapt to a "surprise" situation they best they can. In some cases the GOTO will be highly disruptive; in other cases less so.

Most modern languages disallow GOTO. IMHO it's usually better, even when programming in older languages, to avoid their use unless the language's control structures are truly insufficient to handle a specific, necessary case.

--
Edward E Jaffe
Phoenix Software International, Inc
831 Parkview Drive North
El Segundo, CA 90245
310-338-0400 x318
edja...@phoenixsoftware.com
http://www.phoenixsoftware.com/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN

Reply via email to