In this letter, Dijkstra talks about readability and maintainability in a time where those topics were rarely talked about (1968). This letter was one of the main causes why modern programmers don't have to trouble themselves with goto statements. Older languages like Java and C# still have a (discouraged) goto statement, because they (mindlessly) copied it from C, which (mindlessly) copied it from Assembly, but more modern languages like Swift and Kotlin don't even have a goto statement anymore.

you are viewing a single comment's thread
view the rest of the comments
[–] 21 points 2 years ago (3 children)

TIL that C# and Java have a goto statement.

  • source
  • hideshow 6 child comments
  • [–] 19 points 2 years ago (3 children)
  • [–] 8 points 2 years ago (1 child)

    Please don't link to medium articles. That page is terrible to visit.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (1 child)

    Looks fine on Firefox on Android with uBlock Origin. 🤷‍♂️

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)

    I'm running exactly the same and it doesn't look fine on my end.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 2 years ago (2 children)

    To be fair, await is a bit more like comefrom, and it's been around for a few releases now.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 4 points 2 years ago* (last edited 2 years ago) (1 child)

    Java doesn't. Well, it's a reserved keyword but it's not implemented.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)

    Yeah but we got labels with continue and break, so we can pseudo goto.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)

    Following that logic if, else and while are also "pseudo goto" statements.

    There's nothing wrong with conditional jumps - we couldn't program without them. The problem with goto specifically is that you can goto "anywhere".

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 2 years ago* (1 child)

    In C# at least, goto can take you between case labels in a switch statement (rather than using fallthrough), which I don't view as being nearly as bad. For example, you can do goto case 1 or goto default to jump to another case.

    The only other use of goto I find remotely tolerable is when paired with a labelled loop statement (like putting a label right before a for loop), but honestly Rust handles that far better with labelled loops (and labelled block expressions).

  • source
  • parent
  • hideshow 2 child comments
  • [–] 5 points 2 years ago

    I've programmed C# for nearly 15 years, and have used goto twice . Once to simplify an early break from a nested loop, essentially a nested continue. The second was to refactor a giant switch statement in a parser, essentially removing convoluted while loops, and just did a goto the start.

    It's one of those things that almost should never be used, but the times it's been needed, it removed a lot of silliness.

  • source
  • parent