Goto Leads to Faster Code
pdoubleya writes "There's an article over at the NY Times (registration required) about Kazushige Goto, the author of the Goto Basic Linear Algebra Subroutines (BLAS, see the wiki); his BLAS implementation is used by 4 of the current 11 fastest computers in the world. Goto is known for painstaking effort in hand-optimizing his routines; in one case, "when computer scientists at the University at Buffalo added Goto BLAS to their Pentium-based supercomputer, the calculating power of the system jumped from 1.5 trillion to 2 trillion mathematical operations per second out of a theoretical limit of 3 trillion." To quote Jack Dongarra, from the University of Tennessee, "I tell them that if they want the fastest they should still turn to Mr. Goto."" Ever get the feeling someone wrote an article merely for the pun?
This isn't news, everyone knows GOTO results in faster code than GOSUB
Whatever.
Goto isn't considered bad programming because it slows things down. It's considered bad programming because it leads to spagetti code.
And people who "meticulously hand optomize" their code annoy the crap out of me. Run it, tweak it, run it again. Was the second run faster? Then tweak some more.
ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
I'm in a programming class right now (literally: my notes are open in another window) and GOTO hasn't even come up. It's an intro-level class, but... I see WHY it's used, and it for sure has its purpose, but if there's a more efficient way to program, duh people are going to go for it. And "registration required"? Ha: http://www.bugmenot.com/ (And yes, the NY Times is on there.)
The thing is, "Goto" isn't logical.
Think about it. There is no valid logical operator that says, "Okay, skip everything in between and go to the end." There is no valid logical constuct that allows you to ignore conditions, or to skip steps without simplifying. It's no wonder its so damn hard to maintain Goto code...Our brains don't work that way!
Sure it's quick. How could it not be? There isn't anything to it...you don't have to check anything or clear anything, you just jump ahead.
ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
http://kerneltrap.org/node/553
goto in linux kernel code is not considered harmful. Linus said so in 2003!
Some programming concepts are cleanest when expressed with functions, some with loops and some with gotos. If you have a finite state machine with 7 states and non-trivial logic for transitions, using 7 well-named labels and gotos is cleaner than any other alternative. K&R C book is pretty slim. I think it's not too much to ask anyone to read it and use all the available language constructs and libraries appropriately.
If I use GoTo and make most everything global then am I not saving valuable stack space..?
Separately, there are some great logical solutions to problems involving the use of GoTo-- we use it to manage the class instance variables (and their states) in a multi-threaded application loop where the number of threads is adjustable at runtime.
Cogito Ergo Sum
10 ?"goto statements remind me of 7th grade and looking through the hole in the girls changing room"
20 goto 10
Uhhh - yeah, right.
Forgive me if I suggest you stay firmly within YOUR box, pal.
Goto is used because it is more efficient from the processor's perspective. Function calls have additional overhead. Function calls are easier to follow than a chain of goto's, so most people consider the cost paid in processing time to be well worth the decreased time needed in implementation, testing, debugging, and maintenance.
Even better: Count how many people whine about how many people have completely missed the point of the article. Seriously, I don't see that many people missing the point, but I do see a lot of people trying to make puns out of the name.
www.timcoleman.com is a total waste of your time. Never go there.
I can bet you most universities don't even teach "goto" logic and if they said anything about it, it was: don't use GOTO statements.
I was told this, unconditionally. I was told why as well, and had the matter illustrated with a mere 12 line example of horrific readability. I still use them though, when the call of the dark side is just too strong for me to resist.
May the Maths Be with you!