[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: file.png (47 KB, 1311x506)
47 KB PNG
Give me one (1) good reason why goto is "bad" besides "because Djikstra said so"
>>
>>108965442
thats like saying driving 60 mph is "bad". you are fucking dumb.
>>
>>108965442
what if, hypothetically, "harmful" doesn't mean exactly the same as "bad"?
consider that dijkstra considered programming to be technically impossible
>>
>>108965442
just like heavily nested if, while, for etc., too much of it will make your code very difficult to understand

regarding your little snippet: interesting, I didn't know gcc carves out computed gotos like that. A little weird to see an indirection having lower precedence than a comma operator.
>>
goto pointer is fucking retarded, might as well code in fucking machine code, skip assembly
>>
>>108965442
What the fuck am I even looking at.
>>
>>108965442
he was referring to long jump and set jump in C. goto is harmless in C because it is limited to functions
>>
sister, we already have the goto, we call it "function call"
>>
>>108966364
and for loop
>>
>>108965842
gcc computed goto extension (you need to read goto* as if it was a special keyword)
it's powerful but really not obvious, so don't use it unwisely or often
it's not as evil as longjmp() but not much is
>>
>>108965442
When you abuse goto your code rapidly turns into spaghetti. It's the most spaghetti-inducing programming practice.
>>
>>108965442
call it a fail effect and you would be cool.
but that unfortunately would require you to understand what an effect is, which would be beyond your displayed level of intelligence.
so i guess you will have to do with the (you)s collected from the bait title and the "loka at me i discovered some new thing in c" picrel.
next time. try to cram "turing complete" and "halting problem" into the post somehow, to hit the sophomore trifecta.
>>
>>108965442
In the languages Dijkstra had to deal with, it was bad because it just let you jump to an arbitrary point in memory and continue program execution, which obviously would fuck things up incredibly badly.

In modern programming language (and this includes old languages like C++), goto is structured, and does not let you jump to an arbitrary point in memory, it is no more bad than using keyword break to get out of a loop (goto can be used to cleanly exit a nested loop, for example; one of its main uses together with error handling), or keyword return to exit a function early.

Dimwits and midwits who didn't bother to understand how it works in modern languages vs Dijkstra's time simply assume it must be bad because le expert said so, without even understanding what the expert was actually complaining about.
>>
goto is great. I love writing spaghetti code so nobody can maintain my stuff
>>
>>108965442
It involves shared global state and it will fuck you up. But you're simply baiting.
>>
>>108965505
>too much of it will make your code very difficult to understand
who gives a fuck about that if you're the only person that needs to understand it
>>
>>108965442
This shit was already thoroughly debunked and prosecuted back in 1987.
>>
>>108965442
Because it allows you to shoot your dick off for no good reason other than your language is boomer as fuck and doesn't have RAII or defer-style cleanup.
>>
>>108966707
The problem back then is anti-goto zealots went full structured concurrency autism instead. No continue, break, early return, etc.
>>
>>108966804
skill issue
>>
>>108966833
You aren't hardcore because you have shit tools, boomer.
>>
>>108965442
>>108966707
this is some old wives tale BS used to smoke out people who know the difference between OOP and basic programming architecture

a GOTO is the exact same concept of having dedicated functions that are called, its just not inherently clean and organized. nothing else is different to the compiler
>>
>>108966862
do you get a chub when your web page responds in 500 ms?
do you understand that it should be 50 us or less?
ask not what your compiler can do for you, but what you can do for your compiler.
>>
>>108966892
Nothing about goto has anything to do what you said, tardo. C++ and Rust exist and have the tools that obviate goto 99.99999% of the time and the small percentage where it's semi-valid, is not even standards complaint C.
>>
>>108966878
look at old fortran code. i mean silent gen old, not boomer old. you used to manually write a goto to get back to the top of a for loop. it was easy to jump to the wrong place on accident
>>
>>108966902
your IDE stockholm syndrome is showing, zoomzoom
>>
>>108966917
So you have no argument? Why do you retards say so much and yet say literally nothing at the same time? Where is your defense? Do you even have one?
Outside of computed gotos, what the fuck are you doing with them that can't be better done with RAII style programming where resources clean themselves up on exiting a scope? Even meme langs like go and zig and odin have defer and in fact they're adding defer to C anyway. legitimately, if you're writing C and you gotos aren't basically goto fail; you're probably doing something very wrong.

Feel free to actually say something intelligent. Also even in computed goto case, it seems that tail call is competitive as well.
>>
>>108966940
> RAII
More bullshit fairytales
You’ve never debugged anything and had to look at a JMP instruction.

>>108966909
> what is testing?
>>
10 ?"GOODBYE, BENIS."
20 GOTO 10
RUN
>>
>>108966981
Testing every code path isn't necessarily easy unless your program is dead simple. But you wouldn't know because you think RAII is a "fairytale"
>>
>>108966940
the fat bearded faggot and his lackeys on the c committee can add whatever they want. ANSI C has everything you need.
>>
>>108966981
lol
lmao even
smack the programmer on her ass when she walks by and tell her to get it right next time
>>
>>108965442
the cost is social
>>
>>108965442
I can't, because there isn't.
>>
>>108966500
longjmp has at least one legitimate use case I've seen in production code (error handling (note I said legitimate, not sane)). What the fuck is this abomination for?
>>
>>108967092
Bytecode interpreters.
>>
>>108967128
Ahh, I guess that makes sense, looks like Guile uses it.
>>
>>108965453
>driving 60 mph is "bad"
Correct. Trying to drive too fast is for retarded low IQ narcissists
>>
>>108965442
None. In fact, it's the best way to handle errors in C, definitely far better than exceptions.

Dijkstra was wrong.
>>
@108966585
shut up midwit
>>
GOODBYE, BENIS.
GOODBYE, BENIS.
GOODBYE, BENIS.
GOODBYE, BENIS.
GOODBYE, BENIS.

?BREAK
_
>>
>>108965442
! agree

10 PRINT "SUCK MY UNWASHED ANUS"
20 GOTO 10

>>108965503
You're full of shit, when I load a pointer with a new value pointing to an address in C I'm doing the same thing just less readable
>>
objected oriened programming has been a disaster, programming peaked out at proceedural and there was nothing much wrong with well written unstructured for less complex applications
>>
>>108967275
Even big C projects are cancerous. The problem isn't classes.
>>
You know what I use LLMs for rn?

Z80 assembly.

JP (Jump) or JR (Jump Relative)

and you're all upset by GOTO.


https://www.youtube.com/watch?v=DV2qiOeUT9E
>>
>>108967282
you're everything that wemt wrong in what I love, compuing.
>>
>>108967282
>Even big C projects are cancerous.
brainlets could never handle it so we had to have muh retarded classes and objects to fit in the brains of spastics The machine code does not know what generated it it just knows it is instructions
>>
>>108967322
>The machine code does not know what generated it it just knows it is instructions
>>
>>108967092
We used to use to setjmp/longjmp to implement cooperative multitasking.

I’ve used it once in a while to blow the minds of newbies.
>>
>>108965442
Djikstra was a great man.
>>
>>108965442
Contrarians always say there's nothing wrong with goto, then never actually make a single argument in favor of using goto.
>>
>>108965442
it isn't bad
high levels of nesting are much much worse than almost any amount of gotos
you can write absolute spaghetti with loops and if statements but in assembly programming the level of spaghetti you can create are pretty limited in severity
>>
File: file.png (89 KB, 618x913)
89 KB PNG
>>108967791
goto cleanup is very common, pic rel is from the linux kernel. It's used everywhere in C codebases written by people capable of thinking for themselves.
Also breaking out of nested loops.
>>
>>108967791
C or something
>>
>>108967802
>retard bracing
>leaving struct kw everywhere
chest pain
>>
>>108968020
You will never be a real programmer.
>>
>>108967802
Ya because c is deficient. That isn't a reason.
>>
>>108968031
oh no, dont tell my 23 year career
>>
File: file.png (195 KB, 1017x511)
195 KB PNG
>>108965442
>>
>>108967802
That is a bad example. Why jump to a single function call?
>>
>>108966612
Even some of the shit people came up with in BASIC was unbelievably mind blowing in a bad way. Everyone laughs about 10 print hello; 20 goto 10; but what happened when people combined arbitrary backward and forward jumping into monster loops that did all kinsd of unrelated shit at once was something to behold. The way you could casually discover that a person was oneof these peopleis that they did not understand the reason for subroutine calls (I think gosub) or even theoretically why they could be useful.
>>
>>108968241
23 years of retardmaxxing are not a flex.
>>
>>108968065
goto cleanup >> exceptions.
>>
File: IMG_0651.png (1.87 MB, 1024x1024)
1.87 MB PNG
>>108969643
It kind of is, though.
>>
>>108969663
I'm 24:
>Survived Homelessness twice
>Moved cross country from southeast usa to california
>Been to prison (record expunged)
>Survived 2 hurricanes
It's been a wild fucking life so far
If only I could stay sober shit would probably improve
>>
>>108967791
There are plenty of arguments in favor of goto, but the "goto bad" dogma became so prevalent that people blindly ignore them. Ironically, many of the criticisms that Dijkstra originally expressed towards goto are just as valid, if not more so, with respect to nu-features such as inheritance and exceptions.

In addition to the things already mentioned ITT, see https://dl.acm.org/doi/10.1145/356635.356640
>>
File: IMG_0021.gif (903 KB, 220x220)
903 KB GIF
>>108969670
Sounds a lot like me. About twice your age. After about 25 years on the sauce pretty hard, had to hang up the gloves or the liver was going to go past the point of no return. The funny part is I really did accomplish a lot, I just don't always remember exactly what year it was. Seeing code of yours from a decade ago that you don't remember is always weird.
>>
>>108969651
Wrong. For example, SEH makes sure stuff like mutexes get appropriately handled. goto is an optional codepath that you can forget to implement.
goto is objectively bad at everything.
>>
>>108966612
tfw lua doesnt have a loop continue but it does have goto, Ive used it in prodiction code there
>>
File: 1780448259131.jpg (48 KB, 466x559)
48 KB JPG
>>108965442
it screws up the call stack memory address index.
>>
>>108965442

#include <stdio.h>

int main() {

goto begin;

begin:
goto print_hello;

print_hello:
printf("Hello");

goto print_space;

print_space:
printf(" ");

goto print_world;

print_world:
printf("World");

goto print_newline;

print_newline:
printf("\n");

goto increment_counter;

increment_counter:
goto check_counter;

check_counter:
static int i = 0;
i++;

if (i < 10)
goto begin;

goto prepare_exit;

prepare_exit:
goto cleanup;

cleanup:
goto finalize;

finalize:
goto exit_program;

exit_program:
return 0;
}
>>
Goto is neat and makes things easier to both write and read when there's niche cases that need to restart a process. I miss it when doing higher level languages that don't have it, like JS.

Yes you can wrap it in a loop and use continue to "goto start" but that adds unnecessary indentation and I also don't like for readability, loops indicate that you are iterating over something or doing something repeatedly, so I don't like much for that reason.
>>
>>108970115
>SEH makes sure stuff like mutexes get appropriately handled
Only if you get it right. Just like goto.
>>
>>108969395
It's just a pattern you start applying everywhere once you've learned the effectiveness of it. You don't know ahead of time how complicated the cleanup routine will be, so you just do this by default. And if the cleanup routine needs to be expanded, instead of having to hunt down every instance of the cleanup (there are two of them here), you already have it in one predictable place, at the bottom of the function behind a cleanup goto. Very maintainable.

>>108968020
I literally see no problem with either of those. It's standard bracing and struct keyword in many scenarios keeps your code much more readable. You know right away it's just a struct you can just use and not some kind of identifier or other nonsense hopefully documented in some random ass file you have to go and find.
>>
>>108970298
this. I don't think I've ever written a goto that wasn't named either
err/clean/bail something(due to a lack of defer/drop or the like in C) or again/retry because it genuinely makes it easier to understand.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.