News for hackers. Stuff that matters.
Re:Meta’s Microservice Architecture [pdf] by randomdata on Tuesday July 11, 2023 @04:41AM (#36678078)
> hence nowadays GOTO has practically a niche usage.

Except where it was rebranded as throw/catch. All while bridled (C-style) gotos were considered acceptable by Dijstrka, but are now looked upon with disdain. Amazing what marketing can do.

Re:Meta’s Microservice Architecture [pdf] by gordian-not on Tuesday July 11, 2023 @05:31AM (#36678441)
Aren't you talking about break and continue? throw and catch unwind the stack and goto doesn't
Re:Meta’s Microservice Architecture [pdf] by randomdata on Tuesday July 11, 2023 @09:44AM (#36680866)
break, continue, and even goto in any language created in the last several decades cannot leave the current function. These are not what Dijkstra was talking about. Dijkstra wrote the piece when structured programming was just starting to become a thing and was urging people towards it. Think more like goto in BASIC, where there is no bridling of the operator.
Re:Meta’s Microservice Architecture [pdf] by gordian-not on Tuesday July 11, 2023 @11:36AM (#36682482)
Yes, however I am not sure if Dijkstra meant goto in the sense of jump outside of a function. I don't know enough about Algol 60 and languages of the time, but if you allow usage of goto between different functions you will have a corrupt stack in no time, so I'll be surprised if it was implemented.

Going back to the original discussion, my point was that the only statements that are real gotos still in usage (except for C cleanup gotos) is break and continue, which even support labels

Re:Meta’s Microservice Architecture [pdf] by randomdata on Tuesday July 11, 2023 @12:04PM (#36682975)
Functions do not exist in the context of the "Go to statement considered harmful" paper, so there is no good analog in there. Further, he is specific that it is only about unbridled gotos. continue and break are decidedly bridled. In reality, the paper just doesn't apply to any language created in the last several decades, even those which use the goto keyword. We bought in to structured programming.

Except I posit that throw/catch still suffers the same problem he speaks of. It becomes difficult to follow when and where the code will jump to an arbitrary spot. The harmful parts of goto live on. Granted, we are learning. Modern languages are abandoning the throw/catch concept.

Re:Meta’s Microservice Architecture [pdf] by gordian-not on Tuesday July 11, 2023 @12:32PM (#36683406)
I agree about the somewhat unexpectedness of exceptions, although it is much structured than gotos (you just go up the stack)

virtual polymorphism for example is completely unexpected, as well as function pointers and other constructs that in my opinion are harder to track than exceptions

Re:Meta’s Microservice Architecture [pdf] by whstl on Tuesday July 11, 2023 @06:05AM (#36678739)
Almost everything is a "rebranded goto". Functions, conditions, iteration, break/continue.

Doesn't mean that Dijkstra was wrong, or that they are the same as goto.

Also, throw/catch do quite more than a goto, though. It's not only about stack unwinding, it's about the ergonomics of not needing code that uses throw to have any information about where catch is located.

Sure you can simulate some use cases of try/catch with goto, but implementing the general case is much harder.

throw/catch is exactly the kind of good goto-replacement provided by "higher level" programming languages that Dijkstra is talking about in his paper.

Re:Meta’s Microservice Architecture [pdf] by gjvc on Tuesday July 11, 2023 @06:18AM (#36678868)
> Almost everything is a "rebranded goto". Functions, conditions, iteration, break/continue.

That's like saying all maths is just the application of addition.

Re:Meta’s Microservice Architecture [pdf] by ubercore on Tuesday July 11, 2023 @06:37AM (#36679028)
I think that's the point -- it's nearly as useless to call throw/catch a rebranded goto as it is anything else.
Re:Meta’s Microservice Architecture [pdf] by whstl on Tuesday July 11, 2023 @07:57AM (#36679723)
Yeah. It’s a useless pedantism that serves no purpose in most discussions.

That’s what I have “rebranded goto” in quotes. And that’s what I address in the second paragraph.

Re:Meta’s Microservice Architecture [pdf] by gjvc on Wednesday July 12, 2023 @11:47AM (#36696375)
it failed to satisfy me
Re:Meta’s Microservice Architecture [pdf] by randomdata on Tuesday July 11, 2023 @09:30AM (#36680685)
> Almost everything is a "rebranded goto". Functions, conditions, iteration, break/continue.

Not within the context of discussion, where goto refers to the harmful kind. Throw/catch exhibits the very problem Dijkstra was talking about, with execution jumping all over the place haphazardly. Functions, conditions, iteration, break/continue, even (C-style) goto does not exhibit the same problem. They are strictly bridled in the execution scope.

There is good reason why modern languages are moving away from throw/catch. However, there is little question that it is still widely used at this time.

Re:Meta’s Microservice Architecture [pdf] by patmorgan23 on Tuesday July 11, 2023 @10:25AM (#36681424)
Throw is much worse than GOTO. GOTO is explicit you always know where it goes. Throw has no idea where catch is and catch has no idea where throw is. It's hidden control flow.

Go/Rust/Zig Errors as values is a much better system forcing you to explicitly deal with the error, crash or pass it on. Rather than hoping you handled all the correct exceptions/someone else will handle all of them.

Re:Meta’s Microservice Architecture [pdf] by o1y32 on Tuesday July 11, 2023 @12:08PM (#36683038)
If this were a top level comment I am sure you'll get 20 people disagree with you on this
Re:Meta’s Microservice Architecture [pdf] by randomdata on Thursday July 13, 2023 @10:03AM (#36709319)
Even Dijkstra followed up the "Go To Statement Considered Harmful" letter with the "On a Somewhat Disappointing Correspondence" letter because "20" people disagreed with him.

There will always be naysayers. The above is starting to become generally accepted, though, and modern languages are moving away from the practice just as languages moved away from unbridled gotos.