Why do people hate goto statement so much? It is a really powerful feature. It allows the programmer to understand what is really going on in the generated code. High-level constructions such as IF and WHILE all compile to goto.
The truth is that if you hate goto you don't have enough IQ to use goto.
Goto became unnecessary with the introduction of vtables.
Mason Cooper
I dont use them because label syntax is ugly
Carson Brooks
99% of the time, you can rewrite that goto in some more coherent way. It's basically a crutch for bad design.
Grayson Sullivan
Academics don’t like it because goto fucks up cs theory
These days it’s fine to use in a few cases, in general your code will be better structured if you don’t use it
Owen Allen
>High-level constructions such as IF and WHILE all compile to goto. There is no such thing as a goto in assembly, assembly uses jmp instructions. goto statements in high level languages dont necessarily compile to jmp statements in assembly in fact jmp statements are to be avoided as they can be inefficient and cause cache misses. OP is a typical C (((programmer))) that blindly believes shit people tell him about how C is high level assembly and stupidly thinks he is uses syntax that directly maps to assembly.
Daniel Mitchell
You're literally retarded or have CTE. And nice semantics game, also jmp is used all the time. or jump register, or branching this is why poo cs majors fucking suck
Jackson Lopez
>High-level constructions such as IF and WHILE all compile to goto. The architects of the pyramids did not concern themselves with the shaping of each sandstone, yet each stroke of the chisel contributed to the final structure.
Luis Green
how so? RAII seems a better reason to me
Daniel Gomez
if you write go to statements in any language higher than machine code in the modern day you are a literal drooling mongoloid and the only reason go to is still in machine code is because final instructions can't be abstract
Sebastian Parker
Or you could just put any piece ot code that a goto would cause to run more than once in a subroutine or inline function, and call it all the times you need, with a simple 1-line if or for if necessary. I can't imagine any situation where this wouldn't be the more transparent and readable approach.
Parker Ortiz
>in fact jmp statements are to be avoided as they can be inefficient and cause cache misses
>cause cache misses cause branch prediction misses, ftfy
Caleb Gray
idk i use and love goto
Jaxson Price
Because it fucks up your scopes and when you have nested gotos shit becomes unmaintainable. The only legitimate case when you might want to use gotos is when you're getting out of nested loops (which you shouldn't do that often anyway)
Cameron King
You have to go back.
Ryan Rodriguez
as long as you don't use a goto within a subroutine its fine.
Eli Hill
It leads to shitty unstructured code.
Lucas Foster
jmp is just another name for goto. Unfortunately, modern goto cannot scape the current function, but still it is a jmp.
Nathan Martinez
Because it's not GOSUB
Christopher Perez
>being this butthurt because of naming. My cpus use b/bl/bx instructions.
Daniel Smith
Goto is shit, call/cc is better. Call/cc is shit, delimited continuations are better.
Gavin Ross
>The only legitimate case when you might want to use gotos is when you're getting out of nested loops I'm a CS brainlet, but isn't it pretty much guaranteed that you can restructure your loops to an equivalent execution that doesn't need labels?
>C Real languages have defer or destructors, boomer.
Jackson Cruz
It has a higher probably of causing cache miss too.
Nathaniel Diaz
there are very few langs with defer or destructors
Logan Butler
for whatever reason most languages lack a feature to jump out of nested loops so you need to var = true; break; if var = true break; which performs worse than a goto and is more to type
Easton Foster
stupid question, better question why do people RECURSION so much?
goto statements are perfect for many things: * exiting deeply nested loops * error handling * because i feel like it etc... it's just a branch statement that get's a bad wrap because people abuse it.
Mason Reyes
C++ has destructors. Go has defer. Java, C#, Kotlin, Scala all have try-finally.
Chase Morales
Go has labeled loops and break/continue take optional label. IMHO this is the best option.
Jack Ross
I dont see why you can't just write "break 3" and it breaks out of 3 levels of nested loop
Lincoln Powell
>lists a bunch of bad designs
Jace Ortiz
Java has them too. Good question, probably design focus so that you don't choke on all that sugar a la C++.
Jaxon Hughes
You'd love the game Exapunks.
Daniel Walker
>bad wrap Holy shit, how does language get mangled this bad? >reputation >rep >rap >wrap What's next, "Why does X get such a bad burrito?"?
Nathan Williams
i use goto when writing GOD TIER batch scripts to make my windows 7 experience even better
Levi Perry
The first two reasons are the only valid reasons to use goto in C. In other languages, there are better constructs for those two cases. In Rust, there is break label, which is like a goto, but only works for exiting loops. For complex error handling, RAII is the best tool, since it allows all cleanup code to be handled immediately at the return statement.
Benjamin Myers
Why write batch scripts when Windows 7 has PowerShell, which actually looks like a proper scripting language and can hook into .NET if you need to?
Samuel Peterson
only plebs hate goto. it is a necessity
Zachary Diaz
It is only a necessity in C due to the lack of RAII.
Samuel Wright
and most of the other languages
Jonathan Ross
Forward gotos are useful. Check Linux kernel for good examples. Backward goto sounds like a mistake.
Sebastian Nguyen
I think you use jumps for them instead
Julian Morris
>what are destructors >what is defer >what is try/finally
Joshua Perry
Literally the only language with distructors is c++. The only other language you can control garbage
Gavin Hill
people who are strongly against goto don't understand how pointers work
Cooper Phillips
I think its basically dogma they teach everyone in their first CS class >seriously thinking established practices are based on optimal behavior
Leo Johnson
there's standardized ways to handle your list (except the "i feel like it") goto is not a standard way to make jumps and would be unexpected, thus difficult to debug.
goto was useful after assembly, around the time of basic. but when pascal and other structured languages came around, they organized code in a way that you don't need to track jumps anymore. an if/then/else or a loop is self-contained with predictable and expected jump locations (the compiler handles it).
could you need a goto? possibly. but you had better put in caps in your documents that you have it, so ppl can debug
Kevin Davis
Batch scripts do not rely upon the presence of powershell on the target device.
Lucas Allen
I put my GOTO statements inside a CASE condition using variabe names composed of eight random characters, and document none of it, because I'm King Fucking Douchebag.