[Coco] Question about BASIC coding guidelines
Stephen H. Fischer
SFischer1 at Mindspring.com
Sun Nov 2 17:57:02 EST 2008
----- Original Message -----
From: "Darren A" <mechacoco at gmail.com>
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Sent: Wednesday, October 29, 2008 4:54 PM
Subject: Re: [Coco] Question about BASIC coding guidelines
> On 10/29/08, John wrote:
>> Hello all,
>>
>> I seem to remember BASIC "coding guidelines" said to initialize and
>> declare
>> all variables at the beginning of a program. In addition to making the
>> code
>> somewhat more readable, I seem to remember some minor performance gains
>> from
>> this as well (especially if you declared the most often used variables
>> first).
>
> For performance reasons, you should put all initialization code
> towards the end of the program in a subroutine and then use a GOSUB to
> call it from beginning of your program. The reasoning for this is that
> every GOTO statement which branches back to an earlier line number
> causes the interpreter to start searching for that line number from
> the very beginning. Therefore, the fewer number of one-time-executed
> lines at the beginning of the program, the better.
>
> I seriously doubt there are very many programs that will actually
> benefit from this kind of optimization.
>
> Darren
When developing "Urbane" I did notice that placing the most used subroutines
first did speed up the translatation process.
I was not happy about the processing speed even with the "Run" time version
being as compact as possible and planned additional methods to speed it up
(Machine Language Version).
The first version, the only one released, was developed to be as readable as
possible for humans while still being as fast as possible for Basic to run,
while removing the two character variable and line number limitations of
Basic which make it such an unpleasant language for humans to use.
http://www.coco3.com/urbane/
SHF
More information about the Coco
mailing list