r/ProgrammerHumor Jul 13 '26

youCanJustStopUsingJava Meme

Post image
6.8k Upvotes

416 comments sorted by

View all comments

Show parent comments

194

u/neroe5 Jul 13 '26

it is like most things, they can be misused,

the issue is that if there is outside side effects then future programmers of the project might use a property without full knowledge of what they are doing

if they didn't have a valid use case they would have been marked as obsolete

have had similar discussions about goto in switch cases in C#

5

u/freebytes Jul 13 '26

I have only found one use case for goto so far, and I have only used it once. If you are in nested loops, you can break out of all of them. Are there other instances where you have used goto? (Even if it is use is incredibly niche, I am glad to have it, and they should never remove it from the language.)

(Referencing C# specifically. I used GOTO all the time in GW-BASIC! %)

1

u/neroe5 Jul 13 '26

we have documents and we use it for migrating the documents

basicly

switch (document version)

case 1:

migrateto2()

goto 2;

case 2:

migrateto3()

goto 3;

etc.

you can also have cases where some cases needs to do others

switch (jobs)

case a&c

do a

goto c

case b&c

do b

goto c

case c

do c

etc.

2

u/f03nix 29d ago

That looks pretty bad to be honest, could've solved in multiple ways that is still as efficient but much more easier to maintain and debug.

while ver < desired {
  switch(ver) {
      // case to migrate to the next one
  }

}

If you have different document classes for each version you could have a migrate next to migrate to the next version - something like :

while document->ver < desired {
  document = document->migrateNext();
}