2 ms·
Goto probably doesn't have much of a place in structured programming, but I think there are potential applications for it in more finite domains. Though I neve
by ravenstine 5y ago
Goto probably doesn't have much of a place in structured programming, but I think there are potential applications for it in more finite domains.
Though I never finished it, years ago I was working on a language specifically designed for voice activated devices, interactive fiction games, and so on. I wasn't happy writing Alexa skills using languages like JavaScript because such languages have more features and complexity than are ever used for a voice interface. So I worked on a lexer-parser for a language I invented that was very minimal.
These were the features of the language:
- No syntactical scoping. You have to be explicit about the "data set" you are using.
- Close to being more like an "assembly" language, every line being a command with parameters, but is human readable and declarative, and supports expressions.
- Control flow is done not only through the equivalent of a "goto", but something like "goto chapter" and "goto section".
- There is no syntactical concept of loops. Loops are effectively performed using gotos and conditions.
- Lines beginning with whitespace are interpreted as text or speech to be rendered.
For the purpose of what I wanted to do, this allowed me to focus more on the user experience and less on fitting my ideas into languages designed to support algorithms, OOP, and so on. The simplicity of using gotos meant less conceptual overhead; everything could be done with just if-else, goto, math operators, and negation.
I imagine goto may also be a good way to introduce young kids to the concept of programming, though I suppose that could backfire if they get too used to writing unstructured programs.