Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Why is goto so bad?


  • Please log in to reply
16 replies to this topic

#13 solidsnake

solidsnake

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 13 February 2010 - 02:02 PM

It's same as global variables to me. I'm avoiding it but if necessary why not.
Btw never been in situation I had to use goto since primary school basic :D
  • 0

#14 Moudi

Moudi

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 131 posts

Posted 13 February 2010 - 02:31 PM

i do not have much knowledge in C but from experience ( wish is little ) A few projects i've been working on and when i use goto with "srand" and " malloc " it seems kind of buggy and wierd, maybe its just me and i'm stupid but bleh
  • 0

#15 dcs

dcs

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 730 posts

Posted 13 February 2010 - 02:39 PM

i do not have much knowledge in C but from experience ( wish is little ) A few projects i've been working on and when i use goto with "srand" and " malloc " it seems kind of buggy and wierd, maybe its just me and i'm stupid but bleh

Maybe post such code and possibly someone will tell you a better way? Seems a better way than guessing that your code is "buggy and wierd".
  • 0

#16 bobdark

bobdark

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 155 posts

Posted 13 February 2010 - 04:08 PM

In addition to the code being many not understandable and unreadable, it also might screw up optimization heuristics - for example you jump to segment of code which is not in your cache - your performance goes down badly as a result.
But it indeed does have its uses - search for example linux kernel files for goto. You will find a lot of it there.
  • 0

#17 mmo-dev

mmo-dev

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 98 posts
  • Programming Language:(Visual) Basic, Others
  • Learning:C, Java, C++, C#, PHP, (Visual) Basic, Lua

Posted 13 February 2010 - 04:43 PM

ya i used goto in q basic when i was working in dos but dam i as well haven't seen goto used in such a long time didn't know it can still be used xD but if it can use it to a min. as the top 2 said ull end up with spaghetti code and my my that isn't fun to debug at all trust me i learned the hard way lol
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download