Why do people hate goto statement so much? It is a really powerful feature...

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.

Attached: Image13.jpg (566x316, 30K)

Other urls found in this thread:

wiki.sei.cmu.edu/confluence/display/c/MEM12-C. Consider using a goto chain when leaving a function on error when using and releasing resources
twitter.com/AnonBabble

Goto became unnecessary with the introduction of vtables.

I dont use them because label syntax is ugly

99% of the time, you can rewrite that goto in some more coherent way.
It's basically a crutch for bad design.

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

>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.

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

>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.

how so? RAII seems a better reason to me

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

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.

>in fact jmp statements are to be avoided as they can be inefficient and cause cache misses

Attached: 0cbpdjii3pa11.png (645x729, 105K)

>cause cache misses
cause branch prediction misses, ftfy

idk i use and love goto

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)

You have to go back.

as long as you don't use a goto within a subroutine its fine.

It leads to shitty unstructured code.

jmp is just another name for goto. Unfortunately, modern goto cannot scape the current function, but still it is a jmp.

Because it's not GOSUB

>being this butthurt because of naming.
My cpus use b/bl/bx instructions.

Goto is shit, call/cc is better.
Call/cc is shit, delimited continuations are better.

>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?

wiki.sei.cmu.edu/confluence/display/c/MEM12-C. Consider using a goto chain when leaving a function on error when using and releasing resources

>C
Real languages have defer or destructors, boomer.

It has a higher probably of causing cache miss too.

there are very few langs with defer or destructors

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

stupid question, better question why do people RECURSION so much?

Attached: 1481161629826.gif (499x499, 45K)

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.

C++ has destructors.
Go has defer.
Java, C#, Kotlin, Scala all have try-finally.

Go has labeled loops and break/continue take optional label. IMHO this is the best option.

I dont see why you can't just write "break 3" and it breaks out of 3 levels of nested loop

>lists a bunch of bad designs

Java has them too.
Good question, probably design focus so that you don't choke on all that sugar a la C++.

You'd love the game Exapunks.

>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?"?

i use goto when writing GOD TIER batch scripts to make my windows 7 experience even better

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.

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?

only plebs hate goto.
it is a necessity

It is only a necessity in C due to the lack of RAII.

and most of the other languages

Forward gotos are useful. Check Linux kernel for good examples. Backward goto sounds like a mistake.

I think you use jumps for them instead

>what are destructors
>what is defer
>what is try/finally

Literally the only language with distructors is c++. The only other language you can control garbage

people who are strongly against goto don't understand how pointers work

I think its basically dogma they teach everyone in their first CS class
>seriously thinking established practices are based on optimal behavior

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

Batch scripts do not rely upon the presence of powershell on the target device.

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.

Attached: AM.png (462x309, 244K)

>hating goto while not realizing that every instruction that follows another instruction is a pseudo goto