Hacker News new | ask | show | jobs
by 8note 1278 days ago
Why bother with loop, continue, and break when you can have a more generic if+goto that can handle all the cases?

You can simulate the loop behaviour if that's what you really want

1 comments

I've thought about that, but that's closer to the metal than I prefer and I think it's not beneficial for less experienced programmers.

Structured programming is, I believe, a good idea for the vast majority of use cases. Though one can technically use structured programming while using goto, encouraging goto can therefore allow programmers to go down a path that is counterproductive. It's basically the opposite end of the spectrum from OOP where encouragement of rampant objectiveness and inheritance makes programmers write code that is way too complicated.

There's absolutely a place for goto. I once made a "language" (actually YAML) specifically for developing for the Amazon Alexa platform, and it used something similar to goto called "go to scene" and "go to random". For that sort of thing, goto can be much more practical and even easier to reason about than "better" constructs in general purpose high-level programming languages. It's just not something I would consider appropriate for the kind of language I am proposing, though I still ponder on it.