I'm sorry, but I'm a firm believer that goto statements are considered harmful...
My lecturers shared this view. Unfortunately, since then I've been doing more GNU Assembly than C, hence I've become lazy. I can't be arsed atm to redo it properly with while loops, switch cases and more functions.
I'm sorry, but I'm a firm believer that goto statements are considered harmful...
They're a tool like all other tools in the programming toolbox, used correctly they are quite powerful and can help you optimise your code quite a bit, but then, using them wrongfully you get awfully bad code
Goto statements are most useful in Assembly, in the form of Jumps. Having said that, the CJNE is the equivalent of a While loop.
Was Goto instruction invented for beginner C users that're familiar with Assembly? You can get tighter code with Assembly if you're compact, but if you do every program the same, imo, ppl are better using either C or Basic.
Goto statements were a necessary evil at some point, but today we are rarely interested enough in performance to justify sacrificing good code readability for that.
Truth be told, I haven't thought about goto in almost a decade and that's a good thing. Goto is too dangerous to let the average programmer decide when it can or cannot be used, so we simply say it's evil. Of course you can write good code with goto and bad code without, but you're simply more likely to produce bad code if you splatter gotos and labels all over the code.
That it's tricky to use gotos is very true and for the most part you should avoid them, at the same time, using them correctly can really boost the performance on your coding allowing you to get more for your money when writing very processing intense algorithms.
That it's tricky to use gotos is very true and for the most part you should avoid them, at the same time, using them correctly can really boost the performance on your coding allowing you to get more for your money when writing very processing intense algorithms.
That applies to little beyond realtime applications on microcontrollers these days (having said that, what are cellphones and wireless routers? lol)
That applies to little beyond realtime applications on microcontrollers these days (having said that, what are cellphones and wireless routers? lol)
Routers/cell phones are no realtime applications, that's for sure.
I think in terms of performance a "goto statement" should make no difference. I haven't tried it, but i am pretty confident that compiler optimization will get similar, if not the same, results with or without "goto".
Comments
No comments but I don't think a simple text program needs them. Will get improved if there's a demand.
EDIT: I studied C four years ago and haven't touched it since, ok? I'm rather rusty, hence inevitable mistakes.
I guessed "Because its Non Pirate" Guess I'm even worse than you
And now for another bad joke. What do you call Guybrush when he's handling his inventory?
Answer:
You included a goto statement. DIE DIE DIE!!!
:P
I'm sorry, but I'm a firm believer that goto statements are considered harmful...
My lecturers shared this view. Unfortunately, since then I've been doing more GNU Assembly than C, hence I've become lazy. I can't be arsed atm to redo it properly with while loops, switch cases and more functions.
That's much better.
I'm glad someone appreciates it! It took me a good half hour typing all that out.
We're not commenting for your own good. Spending that much time on a joke isn't healthy!
I had fun reading it too
They're a tool like all other tools in the programming toolbox, used correctly they are quite powerful and can help you optimise your code quite a bit, but then, using them wrongfully you get awfully bad code
Was Goto instruction invented for beginner C users that're familiar with Assembly? You can get tighter code with Assembly if you're compact, but if you do every program the same, imo, ppl are better using either C or Basic.
Truth be told, I haven't thought about goto in almost a decade and that's a good thing. Goto is too dangerous to let the average programmer decide when it can or cannot be used, so we simply say it's evil. Of course you can write good code with goto and bad code without, but you're simply more likely to produce bad code if you splatter gotos and labels all over the code.
That applies to little beyond realtime applications on microcontrollers these days (having said that, what are cellphones and wireless routers? lol)
Routers/cell phones are no realtime applications, that's for sure.
I think in terms of performance a "goto statement" should make no difference. I haven't tried it, but i am pretty confident that compiler optimization will get similar, if not the same, results with or without "goto".
There is a legendary discussion on that topic, by the way.