Goto

What would programming look like today if goto statements had not been "considered harmful"?

Other urls found in this thread:

en.wikipedia.org/wiki/Goto#Criticism
sbel.wisc.edu/Courses/ME964/Literature/knuthProgramming1974.pdf
twitter.com/NSFWRedditGif

goto hell

Everything would be incredibly lightweight.
Complex code simple would not exist as it would constantly fail.
Anything requiring complexity would be broken down into a series of simple programs working together.

Not much different.
These days people use other stuff without moderation, so their code sucks anyway.

probably something like
goto fail;
goto fail;

Gotos still exist they're called jumps, languages just hide them for brainlets

Why are they even considered harmful anyway?

Same as today, goto is not considered harmful in most contexts. That's just a meme and a more apt term would be "jump".
Ie. look at assembly.

They waste CPU cycles

They are not, it's a meme of bad C programming habits and an insult for Basic.

What is a compiler?

en.wikipedia.org/wiki/Goto#Criticism

loop(condition)
some code
loop(condition..)
some code
loop(True)
code
if(condition)
goto: outofloop
label: outofloop

lol

fuck Sup Forums strips whitespaces
just consider the loops nested

Dijkstra said it was bad and therefore single-handedly killed something that was useful.

"goto considered harmful" was a catchy name of an article that became a meme.

compiler/kəmˈpʌJlə/
noun
1. a person who produces a list or book by assembling information or written material collected from other sources.
2. a program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.

oh wow
you fucking
mongrel

Don't use gotos where other methods would suffice would be more apt title for the paper. The problem was people used gotos for everything

What are compiler optimizations.

>The problem was people used gotos for everything
It just werked and CS teachers are losers who couldn't find job in private sector?

I doubt they couldn't find jobs, they probably just like the perks of academia better

I agree with him on everything he defended.

And now people use a whole bunch of other jump statements that are easily abused.

It's almost as if the statement itself isn't inherently bad, but the retards who abuse them.

lmao they hoped by banning all non-crucial code structures they would get rid of badly written code but ofcourse everyone just abuses other statements instead

Mainly they simply don't make sense in the context of most modern languages outside of localized contexts. What does jumping out of a method call even mean?

Furthermore, the need for local gotos is often eliminated by the combination of break/continue statements, early returns, monadic error types, and exceptions. Their use is very situational.

With that said, programming in TI-84 basic or Cobol is a great way to see how a language structured around gotos instead of user-defined functions worked out. Personally, on my TI-84 I often ended up using a few list variables as stacks to get things done, my code often ended up looking like forth ,except when it didn't and i was basically implementing coroutines and cooperative threading by using multiple stacks for the local state of each process, and gotoing between two blocks of code.

For this to be truly appreciated you to read a non-trivial program written in old school basic.

>Anything requiring complexity would be broken down into a series of simple programs working together.
We did that. They're called functions.

There is an known universal argument[1] that goto's provide a way to design certain algorithms in optimal way.
[1}sbel.wisc.edu/Courses/ME964/Literature/knuthProgramming1974.pdf

I remember when having GOSUB was cool.

Seriously, the exact same. Exceptions do the exact same thing, except leave your program in an inconsistent state because you unwind the stack

Exceptions are just obtuse goto's. A throw statement is just a goto catch. Neither are really good and should be avoided because it takes an IQ of 160 to write exception safe code

...

Never really liked spaghetti. Is it something that just grows on you, or am I hopeless? I want to suck on one end of whatever the unit of spaghetti is called while my gf (male) sucks on the other end like those dogs in that movie

What do you not like about it?

>unit of spaghetti
kek. It's called a noodle. What do you not like about spaghetti?

The taste, mostly. But also the flavor.

A lot fucking better. Retard numales think it's some kind of deprecated BASIC thing, when in reality machine code revolves around the fucking things.

Well, you know, that's why you're supposed to add sauce

Do you not like pasta in general? As it is basically the same thing.

>turning your 'ghetti into an ocean

fpbp

this kills the stack

I don't understand how you can eat something you know you only enjoy because of the sauce. How come putting ketchup on your steak is frowned down upon, yet it seems it is considered perfectly normal to hide the flavor of spaghetti?

I don't not like plain spaghetti, but on its own it is pretty bland.

The most important variants of goto are already included in most programming languages.

(continue, break, break $label, function call/return, control structures, exception handling, with-Ressource handling, ...)

because spaghetti is a base carb that doesn't have flavour on its own and steak is meat
same reason you make sandwiches with bread

But good bread is something people actually eat on its own. I used to until I cut down on my carb intake.

pretty rad

would you eat a raw tortilla or a potato by itself
most carbs are tasteless on their own which is why you mix them with something else, pasta is probably the most tasteless cause it's just flour and water

Why would you eat a turtle? Are you brazilian or something?

probably the same. any good programmer uses gotos or exceptions (fancy gotos).

a common pattern you'll see is
a = alloc0();
if (!alloc0)
goto fail_0;
...
b = alloc1();
if (!b)
goto fail_1;
...
return success;
fail_1:
free(b);
fail_0:
free(a);
return fail;


you'll see the same pattern in more modern languages, but it will use try{}catch{}finally{} instead of goto.