Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Not a sin in my opinion:D
Sometimes goto just make sense, there are things that have a higher time complexity when implemented with loops only
So yeah, don't use it everywhere, but don't be dogmatic on not using it -
D--M22687y@ElToastGrande
You should most certainly never use it. Whats the hell is wrong with you
😲😲😲
If you have coded something so complicated that you need to use a goto, then maybe you should make your code simpler.
Like, there is no reason to use a goto. Ever. -
@D--M I'm not talking about complicated. I'm talking about asymptotic runtime behaviour.
I think the proof was written by Donald Knuth, but I'm not quite sure.
I'm absolutely aware of in how far goto makes code less readable.
And I'm not saying "yo, if-goto-loop".
I'm just tired of people bitching around about how bad goto is.
There are gotos in the linux kernel, there are cases in which not using goto increases time complexity.
Don't just listen to easy answers, sometimes there's more to it. -
D--M22687y@ElToastGrande
I disagree. Just because product X used it 20 odd years ago and was super popular 40 years ago does not mean you should be advocating for it.
If we had this conversation 20 years ago where we didn't have as much compute power, I would agree with you.
But son, we are almost at 2018 where we have threads, multiple cores, gpu compute units and cloud services. Any gains you would of made by using GOTOs are incredibly offset by the fact that you have made it intentionally more difficult for someone to understand whats happening.
Gotos are irrelevant. If I ever saw someone use a goto in a code review I would kick their ass so fucking hard. -
Well... I like GoTo... at times... it just seems quicker and easier... always in the same function though...
Saw it in a Linux kernel source as well... it made so much sense 🙄😅 -
@D--M I'm not saying you should use it. However, I'm also not saying you should never use it.
There are situations where you depend on efficiency.
Just saying "well, GPU will do" is a bit easy.
Like I said, it's used in the linux kernel, and it's there for a reason - it's sometimes just easier to get out of a mutiple leveled if structure using goto than screwing around with the ifs.
Really, you can disagree all you want, I don't use gotos, and have never, so it's not like you have to save me from the devil. All I do is telling you there's more to the story.
Also, please, don't call me "son" - I'm really not inexperienced;) -
The only time i use goto is as error handler. If something goes wrong in a function, I use a goto statement to jump to end of the function where clean up (e.g. memory dealloc) is performed before exit. Clear and precise, and common in embedded C programming.
Related Rants
I used a goto. Couldn't figure out how to solve it with loops, due to nested switch, if, for..
rant
wk81