5 ms·
> Python is 30 years old, is there any popular language created in the last 30 years that has goto? Julia (9 years old) https://sodocumentation.net/julia-lang/
by echelon 5y ago
> Python is 30 years old, is there any popular language created in the last 30 years that has goto?
Julia (9 years old) https://sodocumentation.net/julia-lang/topic/5564/-goto-and--label https://sodocumentation.net/julia-lang/topic/5564/-goto-and-...
Golang (11 years old) https://golang.org/ref/spec#Goto_statements https://golang.org/ref/spec#Goto_statements
Lua (28 years old) http://lua-users.org/wiki/GotoStatement http://lua-users.org/wiki/GotoStatement
- ladberg 5y agoWow I'm actually pretty blown away! I use Go on a daily basis and have never seen it used anywhere or had any clue it was in the language. If you had asked me a few minutes ago if Go had goto I would have said "definitely not and they would never add it because it goes against the Go ethos".
- umanwizard 5y agoWhy does it go against the Go ethos? (Asking out of curiosity. I’ve never used the language.)
- ladberg 5y agoI feel like they usually prioritize simplicity and readability instead of tricks, syntactic sugar, and one-liners. For example there's no ternary operator. Instead you'll have to write out a few lines of if/else. There's no function overloading or operator overloading, no built in min/max, and currently no generics (though they're being added). They definitely try to keep the number of keywords down to a minimum compared to languages like Swift where you could write the same business logic in fewer lines using stuff like try, guard, !, and ?.
- withinboredom 5y agoAn if-statement is essentially sugar for conditional jump which is sugar for compare then jump. Goto is a jump. It’s all sugar.
- selcuka 5y agoThe name of the language should have given it away.
- robertlagrant 5y agoHopefully Go 2 won't have Goto
- mumblemumble 5y agoAlso C# (21 years): https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/goto https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... PHP perhaps gets honorable mention for not originally having a goto statement, but adding one something like 10 years later. Zig moved in the opposite direction. It had one at first, and then removed it: https://github.com/ziglang/zig/issues/630 https://github.com/ziglang/zig/issues/630
- AndyKelley 5y agoFor Zig, note that there's not really a use case for goto that you can't do with other language features. To jump backwards, there's labeled continue. To jump forwards, there's labeled break. The use case that computed goto tries to solve is addressed with labeled continue on a switch [1] [1]: https://github.com/ziglang/zig/issues/8220 https://github.com/ziglang/zig/issues/8220
- nerdponx 5y agoMaybe labeled break and continue is what Python needs, not goto.
- rightbyte 5y agoAll that trouble to avoid proper gotos. Essentially introducing castrated gotos.
- Dylan16807 5y agoIsn't that basically every control flow mechanism?
- rightbyte 5y agoYe sure. I meant that it feels like jumping through hoops to introduce a lot of different mechanisms just to remove goto:s. E.g. "labeled breaks" and using silly loop constructs.