Archive for February, 2009

GOTO Addendum

Sunday, February 22nd, 2009

With all this talk of GOTO, it’s suddenly occurred to me that ActionScript has a direct, higher-level version of GOTO that causes Flash projects to succumb to the same problems as those affected by the original.

Do gotoAndPlay() and gotoAndStop() ring any bells, anyone? Dijkstra’s commentary on how a dynamic, running process can be conceptually connected to static source code essentially describes the same relationship between a Flash animation and its keyframes. And old Flash code that uses gotoAndPlay() extensively experiences the exact same pitfalls that old programs did that extensively used GOTO.

In fact, I completely agree with EWD- that although these functions are extremely useful, the quality of a Flash program generally correlates with the frequency of gotoAndPlay() and gotoAndStop() in its source code. I know this from personal experience; it wasn’t until I expanded my knowledge of ActionScript and began using structured code that I could really achieve anything in the medium. (more…)

Reviewing “GOTO Considered Harmful”

Saturday, February 21st, 2009

I just looked into an old paper– “GOTO Considered Harmful”– and I found something bitter about EWD (Dijkstra).

GOTO is understandably bad from a present-day perspective; it allows a thread to jump to basically anywhere in a process, and even in situations where it is used respectfully, it is difficult for the programmer to indicate so in his or her source code. But GOTO did something that lots of people could appreciate; it allowed an inner loop to break out of an outer loop. It essentially allowed a complex iterative process to end before the iteration could be completed, without any nutty boolean flags.

Nineteen years after Dijkstra’s rant against GOTOs, a guy named Rubin wrote a counterargument. (This was in 1987, about the time I was born.) By then, GOTO-independence was almost a religious (read: irrational) doctrine. Rubin’s rebuttal reinitialized dialogue about GOTOs. Most people involved in the discussion pointed out that the strength of GOTO could be inherited by some sort of more restrained flow control successor, one that couldn’t just jump around the process. [It should be noted that the formulation of our most common present-day flow control statements were highly influenced by EWD. -Ed.] Rubin’s stance was that at the time, code that used GOTO properly was less cluttered and more readable than code written to deliberately avoid GOTO, and that therefore EWD’s 1968 proposal to eradicate GOTO had a harmful effect on programming efforts.

Dijkstra replied, and here’s what gets me; he noted some errors in Rubin’s code– mostly failures to comply with an orthodox writing style– lambasted him for being an amateur, used computer science to achieve a difficult-to-read solution to Rubin’s example problem, and basically called the man and the other contributors to the conversation “unprofessional”.

It’s too bad the discussion didn’t take place yesterday, or I’d troll him on a message board somewhere.

I believe and can understand that Dijkstra was coming from a different perspective- a highly technically informed one. He was in the middle of a major movement attempting to bridge programming with highly abstract mathematics. But programmers typically will not pour over algorithms to produce code, mainly because it reduces the reader’s comprehension, a principle ironically similar to EWD’s original incentive to ban GOTO in the first place! Wouldn’t it be better to write code that can be understood by those responsible for maintaining it? (more…)