DEV Community

Discussion on: Is goto all that bad?

Collapse
 
nestedsoftware profile image
Nested Software • Edited

Consider a very primitive programming environment where there are only global variables, no functions/procedures, and no control structures like if statements or loops. In order to write a program in such a system, you'd have to jump around in the code from one label to another using goto, modifying global variables as you go along. This becomes extremely hard to understand and maintain as a program gets bigger.

In general it's definitely helpful to have structured code with loops, conditionals, and named functions that have their own variable scope.

Collapse
 
pauljlucas profile image
Paul J. Lucas

You're mostly describing assembly, or BASIC. BTW, you can't write programs without if-like statements. Even assembly has them.

Collapse
 
nestedsoftware profile image
Nested Software

Thanks, you're right. That was definitely a brain lapse on my part! Indeed, I was thinking of old basic or perhaps some of the older machine languages as well.