PDA

View Full Version : A 'cussin bout for a four letter word



Lima Bean
10-12-2011, 11:12 AM
The infamous "goto" rears its head again.

I have come across varying levels of opinion of its usage, and code bases that have it buried in it, not to mention the fact it is equivalent to assembly language jump command.

After reading up on Concurrent Pascal I came across a programming reason not to use it:
"A programming language that permits unrestricted use of assembly language features, such as jumps, typeless machine words, and addresses is insecure."
</b>Monitors and Concurrent Pascal: A Personal History, Brinch Hansen<b>

http://cs305.com/book/programming_languages/Conf-01/HOPLII/p121-hansen.pdf

When reading this short paper it sounds like foundations of popular Oses today, as well as the forecasting of bugs and viruses.

I got to this paper through references etc, a dual stack in memory on a 4k ram machine... wow(that is in a nerd way...lol).

His programming philosophy was to be abstract and secure, goto don't fit it.

Now I am beginning to really understand why G8tes has been accused of spreading the biggest virus on the internet.

Echo_
10-20-2011, 07:33 PM
I enjoy Edsger Dijkstra's opinion on the goto statement :)

http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html

i luffs yeww
10-20-2011, 08:46 PM
I don't think it's fair to say that because Windows uses goto (I have no idea if it does, you just seemed to hint at it) it's bad. Microsoft programmers and Edsger Dijkstra are two entirely different things. If you've ever worked for a company programming, I'm sure you can understand.

What programmers are paid to do for companies (usually, I suppose) is to make things work. Nobody really cares how well the programs are written, as long as performance and aesthetics are good.

Anyway, I don't use goto. I don't like how it looks, mainly. Also there are more clear ways for the same functionality, arguably.

masterBB
10-20-2011, 08:52 PM
Very clever link full of good arguments. (http://xkcd.com/292/)
All I wanted to say.

Coh3n
10-21-2011, 12:39 AM
I still don't understand why people dislike the statement so much (no, I'm probably not going to read the articles posted in this thread). It's used in MSI and does exactly what we want, and there's really no good, clean alternative (if someone wants to see the code I'll post it).

Bixby Sayz
10-21-2011, 12:58 AM
Ironically most (all?) of us use it in our scripts indirectly without even knowing it (assuming the interpreter implements "proper" pascal).

Pascal allows for one entry point to a routine (the top) and one exit point for a routine (the bottom). When you sprinkle your code with exit statements you are saying goto the end of the routine, at which point it actually exits.

Bad code is bad code, regardless of whether it uses goto or not. I've seen some really lousy code that didn't use goto. I've also seen some really elegant well written code that does use goto.

Edit: Just read some of the references. What rubbish. Blah Blah Blah because some people abuse goto the use of goto is bad. We should banish it! blah blah blah whine whine. Sounds suspiciously like a lot of the political reasoning you hear.