Goto is bad

>goto is bad

Attached: 268zj7.jpg (645x729, 26K)

Other urls found in this thread:

literateprogramming.com/adventure.pdf
alexsexton.com/blog/2009/07/goto-dot-js/
twitter.com/NSFWRedditImage

>wojack meme is le funny XD

It is bad

goto

>i'll make myself look retarded to pwn this guy on Jow Forums

goto and recursion are things that sound good in theory, but should never be applied in practice

10 PRINT "KYS NIGGA"
20 GOTO 10

recursion is great

Recursion is kind of cool when you’re mirroring a local directory structure to a remote server and have to walk it file by file by directory.

I had ftp in mind

recursion seems ok to me

int login(){
get(username);
get(pass);
if (username == correct && pass == correct)
continue();
else
login();

Wow look at this hard to understand practice

Woops dropped my last curly }

Remember to put a depth limit in the arguments tho.

>programming with goto is like trying to play chess without moving your pawns
That was said a few times by a professor of mine that was so anti-establishment that Jow Forums would probably suck his dick dry.

>his shitlang doesn't guarantee tco
lol

*without

Here are the main reasons goto was heavily demonized about 30-40 years ago:

>When reading code, goto can make it harder to follow control flow and understand the code.
>Code that has been modified to work without goto typically works better with data flow analysis in optimization stages.
>(More like 20 years ago) the rules of goto complicate lifetime for objects, this is especially painful in C++ and I imagine most C++ programmers don't actually know these rules.

The first two can happen with or without goto, the major complaint against goto 30-40 years ago was that people overused it and to try and speed up moving to structured programming they made claims that goto was inherently bad. There are still cases where goto will clean up code but it is buyer beware with the lifetime rules in C/C++. Bear in mind these are the exact same rules applied when jumping into a switch statement, so if you structure your code without as many assumptions (like people do in switch statements by just having a list of case statements at the first block's scope) then this isn't a problem.

Some situations where goto is preferable:

>Breaking out of a nested loop
>Providing immediate entry to cleanup routines on errors/exit at end of functions

:vagina
start penis.bat
goto vagina

Both of those can be done in a structured way too. Some people don't understand that.

However well used goto statements where required isn't a problem and not what most complain(ed) about.

Yeah I agree, the issue was people preferring goto because they were backwards.

But we're beyond that period, there aren't people like this anymore they pretty much all died out. People should use what makes sense, not what is conceptually easier/lazier for them because they don't like trying new things. It applied back in the day to those overusing goto, and it applies now to those who refuse to touch goto.

Why would you ever do this, when you could just do-while? Are you intentionally trying to be obscure about it? Are you this much of a showoff that you prefer this over the more convenient and manageable do-while, where semantics are one-to-one with the task in hand, and not just the outcome?

>inb4 some shithead asks how
int login(){
do {
get(username);
get(pass);
}
while (username != correct || pass != correct);
continue();
}


>inb4 someone says their meme language doesn't have do-while

please be b8
I refuse to believe someone can be so retarded

I prefer the recursive style it's somewhat clearer. The function construct is already there, you're introducing another construct (the loop) because you are not comfortable with recursion.

It's the Haskell way tho

>listening to numale soiboi javascript code artisan's advice
Lol

goto is fine
comefrom is the real issue

> Risking a stack overflow on login

Attached: 1528683600516.jpg (287x287, 10K)

when goto is good:
-labels to escape nested loops, but actual loop labels and continue/break having optional label argument if a safer feature
- in long procedure to jump to unified cleaning and error handling in language without automatic resource management
- in switch statement to create magic code in critical parts thus ensure your job

Explain what's wrong with it (I'm hoping you know what tail calls are before replying that way).

this nibba is woke af

goto implies your code isn't modular
if you aren't writing modular code, you're an idiot and your project will be shit

>goto implies your code isn't modular
Absolutely not. Prove it

no it isnt. its the only sane programming paradigm

Who are you quoting?

now show how to do the same thing without goto

10 COMEFROM 20
20 PRINT "KYS NIGGA"

Unless you're using a language with TCO, this is absolutely retarded

Goto on its own is not bad. Using it when you can use proper structure is. There are times where you're in nested loops and goto is the best option.

now show how to do the same thing without goto nor comefrom

return, continue, break are all forms of goto
Generally it should be avoided and not taught to first years but it has its uses

>sane
>literally jumping to whatever place and relying on programmer to make these jumps consistent
how this is good, faggot?

10 FOR I IN ... fuck

I think GOTO and GOSUB (call a subroutine) were the only flow control commands and I don't remember if there were for/foreach/while equivalents. Sorry fampai.

yea but your stack will be ass fucked after 1000 gorillion attempts

show me the alternative but without arbitrary variables required to make it work

Google "tail call" right now

for /f %a in (penises.txt) do (
call :vagina %a
)

Goto has its uses, but for the most part it just makes programs harder to trace and should be avoided.

ay nibba u woke af, so the compiler can optimize this code:
int login(){
get(username);
get(pass);
if (username == correct && pass == correct)
continue();
else
login();

into:
login:
int login(){
get(username);
get(pass);
if (username == correct && pass == correct)
continue();
else
goto login;

Tbh it's Edsger Dijkstra fault goto is such widely detested, people don't know it's good uses and effectivity.

Yeah pretty much, one looks nicer than the other though. Pretty much all uses of loops/recursion vs goto build the same code in the end though.

Weirdly if you read his arguments they're well founded and people took it out of context because people only remember catchy headlines and memes and not rationale.

God it's like they're basically millennials who were born earlier.

I see, thank you. The compilers are so artificially smart these days that they can optimize such things... Pretty cool actually.

If you aren’t a boomer who started on Fortran there’s no excuse to use it.

I agree with you, i worded myself wrong. His arguments are good indeed, if you write messy goto code it can turn into a clusterfuck. But used carefully and if it's use is clear and you are able to follow the code flow there's nothing wrong with using it. I mean fuck; continue and break are basically goto's disused under another name.

>disused
disguised

Holy shit you're retarded

not him; explain why.

> return, continue, break are all forms of goto

They are closely related abstractions in flow control, but none of them are actually a subset of any other. Out of them, goto is the only unrestricted one, and break is the only other that is (in some languages) parameterizable at all.

There is absolutely nothing wrong with

continue
break
goto

You just need to know when to use them.

i suppose they all compile into somewhat similar assembly code, i'm almost certain each and every keyword generates a JUMP statement.

It does. Because that's your only flow control CPU instruction that's appropriate for this. The call-ret and int are not appropriate.

You could also do something like "mov esi foobar" but that's just dirtier version of "jmp foobar".

is this series of posts a joke?

Finite-state machines, moron.

Why do you even need goto? You fucking moron, current software works fine without goto.
Every single competent person or book author on subject of programming says to avoid using goto because it makes code harder to read and can add unwanted side effects.

And there's you. A literally no one, saying it's a good thing.
Fuck off.

goto's use should be avoid whenever possible and only be used to move downward

Retard.
literateprogramming.com/adventure.pdf

They're assuming no TCO or don't know what it is

nobody cares about your blog

I'm flattered to be accused of being Knuth, but sorry, I'm not.

Recursion is ugly, inefficient, and should only be used when theres no better alternative(naturally recursive problems). You are a retard

Anyone who calls himself "literate programmer" is worth no attention.

>Recursion is ugly
opinion discarded

Found the lisp/haskell autist

fucking why not just recursion within get function retard? REEEEEEEEEEEE

>tonight we will be preparing an italian classic, spaghetti
>first step, throw out your flow control

alexsexton.com/blog/2009/07/goto-dot-js/

Attached: 1528768650456.png (500x422, 93K)

depends on the lang, really.
Tailcalls should be fine in any language that supports recursion.

Attached: 1529172642690.jpg (613x531, 36K)

CL has loop, which iirc compiles to GOTO statements. Main difference is, it uses symbols not integers, which is a smarter solution.

Attached: 1528586455828.jpg (1440x2960, 795K)

goto is the best way to jump out of nested loops without leaving the function(return)
Alternatively you can write a escape procedure for each loop but I wouldn't consider that a cleaner solution.

#NotAll things considered harmfull are harmfull.

nonlocal exits, for example signals.

Attached: __hoozuki_hoozuki_no_reitetsu_drawn_by_kintaro__141b803e4fb5aff4d19304f523ca1f76.jpg (800x1009, 190K)

#HardlyAny things considered harmful matter on anything but a "go write a paper about it" level.

You were right and I was wrong.

username == pass

>Breaking out of a nested loop
Extract it to a function and return from it.
>Providing immediate entry to cleanup routines on errors/exit at end of functions
RAII
There really are no reasons to use goto.

Finite-state machines.

>used carefully
>trusting programmers
you should always assume programmers are the dumbest monkeys imaginable. the only things they will not fuck up out of incompetence are the things they will fuck up out of malice.

just look at perl. you can write readable code, but it isnt enforced.
>uh, b-but a "good" programmer would only use best-practises, proper indentation, one-statement-per-line, no perl-magic-hackery etc.
this is not how the real world works. if you give a monkey a gun, doesnt matter how often you tell it to "be careful", they *will* manage to shoot someone.

thats why python lives, and perl is dead.

Mr hacker, bring me 50 wrong logins (bumbumbumbum)
Make it explode the stack within (bumbumbumbum)
I'll keep posting dumb shit on clover (bumbumbumbum)
While people pwn me all over...

Better stop using compilers and interpreters, then. And most parsers.

>goto is the best way to jump out of nested loops
that would be something like break(n); or break loopname;

>programming in java

What else would you do with it?

Uninstall.