Appendix E. Fast and Efficient programs

Programming

The book which accompanies this one, Start Programming with the Electron, is intended as a guide to writing programs in Electron BASIC. Once you start writing your own programs, however small they may be, please make good use of the Start Programming with the Electron book. It will help you to develop a good style and help you to avoid getting into bad habits. You will find the programs referred to in the book on the Introductory Cassette.

Speeding Up Programs

There may be times where the program must run as quickly as possible, and here are a few tips for increasing execution speed.

  1. Use integer variables rather than real variables whenever possible.
  2. Use integer division (DIV) rather than normal division (/).
  3. Use integer arrays rather than real arrays.
  4. Start your variable names with different letters of the alphabet.
  5. Omit the control variable after the instruction NEXT.
  6. REPEAT...UNTIL loops are faster than IF...THEN GOTO loops.
  7. Use procedures instead of GOSUBs.
  8. Use as few line numbers as possible by using a colon to separate each statement.
  9. Leave out as many spaces as possible, without confusing the computer.
  10. Omit REM statements.

Some of these tips will have the effect of making your programs less readable. This is not a good thing, but in cases where speed is all important, you may find that you will have to reach a compromise between readability and execution speed.