Jump to content

Basic Programming. Using GOTO. Do you still use it?


Recommended Posts

This has been a topic since the later 1980s. Is that using GOTO's in Programming is bad. At least unconditional straight GOTO statements. The theory is the more GOTOs a program has, the more bugs it has and the harder it is to fix something if it is not functioning correctly. I know the default Atari Basic, makes it hard to write programs without using them, because you need to do IF-THEN-GOTO to execute code that takes several lines if a condition is true. Also need GOTOs to create Loops in Games or other programs. I know Basic XL, Basic XE, Turbo Basic, and Fast Basic include statements like IF ELSE ENDIF, REPEAT UNTIL, WHILE WEND, DO LOOP. These reduce the need of GOTOs. With Atari Basic, I need to use GOTOs with IF statements to simulate the function of a Block IF. This is also happening with Atari 7800 Basic.  
 

 

Edited by peteym5
Link to comment
Share on other sites

It's never been a problem for BASIC users.  I've always heard criticism from C and assembly oriented programmers.

I've tried switching to user routines and gosubs but the additional CPU overhead always gets me in trouble.

 

UPDATE:  I'm not picking on anyone who comes from a lower level language background.  Just my own personal impressions over the years.

Edited by slobu

Please check out my Atari 2600 party favors at https://theloon.itch.io/  

Downloadable games include Upp Plus Plus, Stranglehand, Nitebear on Sleepystreet and more!

Link to comment
Share on other sites

I agree line numbers were also a major issue with earlier Basics. Programmers tend not to include comments to save memory. Plus some basics can execute GOTOs faster than GOSUB RETURN. All you see if GOTO 3000, without knowing what happens at line number 3000. This is also known a "spaghetti code."  When I learned about structure programming in college, my whole world of game making changed. It is also other Basic's available for the 8-bit that changed things like Turbo Basic XL, Basic XL, Basic XE, and recently Fast Basic. 

 

Link to comment
Share on other sites

Spaghetti code is/was a way to protect your work in a weird sort of way.  It was a way to make sure that only the author knew what was going on.  If they got canned and the project handed to someone else the next person would have their work cut out for them.  

I try not to use REM statements not because of program space because those are ignored.  If I do use them it is to map out game ideas of what I am trying to accomplish.  I have nothing against using GOTO, GOSUB, or any other program flow syntaxes or remarks. 

Link to comment
Share on other sites

1 hour ago, Atari 5200 Guy said:

Spaghetti code is/was a way to protect your work in a weird sort of way.  It was a way to make sure that only the author knew what was going on.  If they got canned and the project handed to someone else the next person would have their work cut out for them.  

I try not to use REM statements not because of program space because those are ignored.  If I do use them it is to map out game ideas of what I am trying to accomplish.  I have nothing against using GOTO, GOSUB, or any other program flow syntaxes or remarks. 

I'll be honest with you.  As a person that has been a profession software developer for over 30 years, and someone that has hired many software developers...the minute I catch this attitude from someone, I won't hire them or I will try to train it out of them.  I completely understand this point of view, but the other side is the huge risk to whoever owns the software.  If you win the lottery or decide to move on, the company will suffer. 

:) :) :)  

But for your own personal programs, go for it. 

Link to comment
Share on other sites

I use to hate REM statements but I have gotten to where I use them often and especially in work explaining what a section of code is trying to accomplish.  Being I was the only one programming many moons ago, and not wanting any one else to take my work, I avoided REM statements but had a hard copy with remarks present.  

With web design I use remarks everywhere, and in BASIC, except with the small code I just shared, I use them first to outline what I want my program to accomplish.  I then build my program up from there.  I just wish I knew what I'm supposed to use to compile my Atari BASIC programs into stand alone programs.

Link to comment
Share on other sites

The issue with Commodre 64, Vic-20, Atari 8-bit, Apple II, TI-99, TRS-80, etc. is these systems had very limited resources by default. The Basic was stored in ROM and could only do what fit inside there. It goes back further to mainframes. So we can get away with GOTO 1000 with a smaller program. But as computers got more powerful, our programming had to evolve with it. Turbo Basic and Basic XE on the Atari allowed you to use labels that you can direct program flow to. The issue I am having is that I am converting stuff from 30+ years ago to Fast Basic, and need to figure out what something does.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...