TWO BASIC COMPILERS

Reviewed by Mark Sealey

INTRODUCTION

The first Basic compiler for the Archimedes (version 1 of ABC from Dabs Press) was reviewed in RISC User Volume 2 issue 2, and readers are referred to that issue for an introduction to the role of compilers in general. After a long wait, ABC2 (which will be supplied free of charge to all existing ABC owners) has been released together with a rival product, RiscBasic from Silicon Vision.

This comparative review looks at the operation of each package based on the following five criteria: features; ease and flexibility of use; speed of compilation and execution; size and manageability of object code; documentation and presentation.

In the interests of fairness, the two compilers have been tested using identical source programs (with half from Dabs and half from Silicon Vision and other common benchmarks) plus a representative selection of published and unpublished Basic programs, typical of what any Archimedes user is likely to have to hand.

RISCBASIC

RiscBasic will run under Arthur 1.2 or RISC OS, though the version available at the time of review was not multi-tasking. By the time you read this, a fully multi-tasking version of RISC OS, which I have seen in pre-release form, should be available. This does not alter the RiscBasic compiler itself, but the environment in which the compiler runs, and all the current features of the compiler will remain the same.

RiscBasic is then installed as an application on the menu bar, allowing Basic source files to be compiled by merely dragging the appropriate file icon onto the RiscBasic icon on the Desktop menu bar. However, it still appears to contain features, such as assuming directory pathnames, which are incompatible with Acorn's RISC OS philosophy. This version will be sent out to all purchasers of RiscBasic who have registered with Silicon Vision.

In use, the compiler can be invoked with a single command, which may contain parameters (marked with a minus sign), and must also contain the name of the source code to be compiled, e.g.:
RiscBasic -verbose Myprog

RiscBasic can also be menu driven. In this case the user is presented with an uncluttered and highly legible screen with two windows. The first gives access to operating system commands and allows the user to run the compiler. The other window permits the selection of up to 17 options, which fall into four broad groups affecting speed, comprehensiveness of compilation, the management of source and object code and error-checking. A -debug option, for instance, provides run-time error reporting. Clicking on any one of these options is exactly equivalent to adding it as a parameter if RiscBasic is called as a star command.

The -turbo option will produce faster code if FOR-NEXT and REPEAT-UNTIL loops have single exits. The -width option allows the inclusion of the Basic keywords WIDTH and COUNT but produces slower code. Two options (-OS0 and -nomap) produce code compatible with earlier versions of the Operating System than 1.2 while -single forces single instead of double precision floating point arithmetic.

The -verbose, -stacktest, -nowarnings and -spool options assist in error-checking and tracking what is happening during compilation. Cross referencing is provided by -dump. There are also useful options to change the object filename and to drop you into the ARM Basic Editor at the errant line if a source error should occur. RISC OS no longer holds the Basic Editor in the Operating System ROMs so it must now be loaded first. However, on exiting from the editor, it is still necessary to restart the whole process. With both packages, this is easier and more elegant in the Desktop environment.

Basic programs can be compiled into relocatable modules, including ones with multiple star commands, and RiscBasic comes with many useful demonstration files. As with ABC1 and ABC2, directives (up to 27 here) can be placed in source programs to control some of the compiler options just described - as well as operations like conditional compilation, constant and register variable allocation, and relocatable module functioning.

Before looking at the performance of RiscBasic, one or two other features must be mentioned: rather than leaving sections of ARM Assembler code within a Basic program to be assembled each time the object is executed, Silicon Vision's product assembles the source code and links it, placing it at the end of the compiled code, but this does rule out conditional assembly, and the assembled code can no longer directly access the values of any Basic variables, which is a major limitation.

Silicon Vision's quite plausible point of view is that a Basic compiler is a tool to be used quickly and without fuss. Details contained in their 20-odd page documentation are more than adequate. Run RiscBasic: everything in BBC Basic V (apart from EVAL and the keywords associated with HIMEM and INSTALL), will compile. Let the compiler do the work. Needless to say, the compiled code will multi-task where appropriate.

Silicon Vision has a commendable policy of continually updating its products. The addendum to the manual contains details of minor improvements, for example, in module handling. The buyer who has filled in the registration card may be assured, though, of getting major upgrades free of charge.

ABC2

ABC1 was already a substantial product, and purchasers of the original receive a free upgrade and manual. This is just 30 pages long and lists the improvements, fixes and changes, of which more later. As before, there is a separate examples disc, which contains the old programs as well as some new ones, with very honest notes as to what changes in speed are likely to result from compilation. An ABC 'extras' disc is expected to be released in the near future containing a cross-referencer, library-maker, and profiler and tracer.

The compiler (v.2.29) will now also start from the Desktop, and runs as a non multi-tasking application under RISC OS. Files to be compiled are simply dragged onto the ABC icon. Otherwise there is little difference in appearance or use. Because the library routines have been put into a module, this must be present for any object code to run.

As before, code is given default names and can be compiled from disc or memory. The cycle of compile-debug-compile can become quite mechanical, and it is unfortunate that the filename windows in the Arthur version neither retain the current name nor allow one-key deletion, and that the same default file name ('Object') is always given under RISC OS.

It can still be run either from the command line or from its menu screen. As before, there are one or two user-unfriendly features: the default file-paths suggested during installation (which only works for Arthur 1.2 anyway) do not work with a single disc drive. On the other hand, commands for allocating heap and stack space have been improved. Like its rival, the Dabs compiler is undergoing continual upgrading, and any major changes will be supplied to existing owners free of charge.

Some of the additional features supported by ABC2 are: double and extended precision (19 digits) floating point variables. These are explained most clearly in the documentation as is the use of the TYPE directive to control them. Local error handling has been vastly improved. So has implementation of procedure RETURN parameters. The rules relating to procedure structure have been relaxed. There are also improvements in a number of areas associated with register and variable names.

Some twenty odd known bugs have been fixed and these are well documented. Features still not supported (which are present in RiscBasic, though) are local arrays, multiple entry to FOR, REPEAT loops and some Basic keywords (COUNT and WIDTH, for instance) in addition to the usual limitations with HIMEM, INSTALL and the like.

COMPARATIVE TESTING

By far the fairest way of comparing the two compilers in any quantitative way is to take a variety of benchmarks (supplied equally by the two publishers), run them under identical conditions, and compare the results side by side (bearing in mind the limitations of benchmarks as such).

The following results emerged from averaging ten recorded timings, all in mode 0 with the background check for Escape enabled, using single precision floating point arithmetic so as most closely to resemble interpreted Basic V. All tests were run on a 410/1, loading both the compiler and source code from a floppy, not a hard disc.

To start with, the same benchmarks as were published in the earlier review were used with both compilers. The time (in seconds) is that taken to RUN each routine.
 Basic V ABC2RiscBasic
GrafScreen1.460.850.71
TextScreen2.192.031.99
IntMath1.600.290.15
RealMath0.220.240.25
Triglog1.002.762.73
Sieve4.520.450.06
Fibonacci7.331.150.14
Ackerman4.010.270.16
IntArray1.290.320.05
RealArray1.381.150.09
StringArray0.881.030.11

The following loop benchmarks (100,000 iterations) were also run on each version:
ForLoop18.3514.431.34
RepeatLoop 9.94 1.430.09
WhileLoop 7.68 1.420.11

A representative selection of the (mostly graphics) files supplied by DABS:
3D 1.02 1.011.01
Bounce10.06 2.082.02
Fireworks 7.24 3.563.72

and lastly three more substantial programs:
Stringsort(1)124.0119.098.18
Sort (2) 3.77 0.360.13
Raytrace (3) 15.36 7.947.83

(1) 200 6-character strings - bubble sort
(2) 200 random integers in two arrays
(3) timings in minutes

The average resulting object code sizes and compilation times were similar. If anything RiscBasic's were better, despite having to contain all runtime routines (ABC uses an additional module). The two compilers were also well matched for accuracy.

Yet, such benchmarks must not be taken just at face value for a number of reasons.

Benchmarks such as Grafscreen are limited by the speed of the operating system and test its speed more than the number-crunching capabilities of a compiler. If all those benchmarks which do not rely heavily on the optimisation routines of the compiler (such as Sieve and Fibonacci) are excluded, the superiority of RiscBasic's speed is all the more striking.

In attempting to provide a fuller compiler, coping with all Basic V syntax, RiscBasic incurs certain necessary overheads which you would expect at times to slow it down. In fact - thanks to its more efficient library routines - this is not the case as is shown, for instance, by the bubble sort routine handling Basic's SWAP keyword.

This also explains why the timings are inconsistent in favouring first one then the other product, and makes the computation of meaningful averages so difficult. In the end, the choice is between the better of the two option routines within the compilers. RiscBasic's seems to have the edge.

The benchmarks nevertheless indicate that code compiled by RiscBasic does run faster than that by ABC2, and by nearly 60% on average. What's more, RiscBasic is over three times faster than interpreted Basic V.

In most cases RiscBasic also compiles more quickly than ABC2 (on a range of programs, compile times varied from 7sec to 59sec with ABC2, 4sec to 24sec using RiscBasic), but it does take some extra 12 seconds to reload the RiscBasic compiler each time. The compiled object code requires substantially more memory than the original Basic program, and RiscBasic is more demanding in this respect than ABC2. For example, the same selection of programs ranging from 3K to 10K in size, compiled to 8K to 21K with ABC2, but 23K to 37K with RiscBasic. However, remember that at run time, ABC loads a library module which wipes out its advantage here.

You should also be prepared for some disappointment, when trying to compile your own Basic programs, arising from the occurrence of syntax unacceptable to the compiler. In practice, using a random selection of RISC User programs, this happened quite frequently, though more often with ABC2 than with RiscBasic. One small bug was located in the RiscBasic compiler (since corrected by Silicon Vision), but it is possible there are more.

CONCLUSIONS

Both products are very well presented, and well supported by their respective publishers. In practice Dabs' documentation is far more substantial and much more detailed, now providing over 230 pages of information. Yet Silicon Vision's compiler is definitely the more complete one. Their product produces faster code. It outperforms ABC2 in a number of ways - speed, easier multiple star commands for relocatable modules, and fuller array handling, for example.

Almost as important is ease of use: to the first-time ABC2 user paying nearly £100 for a compiler, there are a number of operations, particularly with the Arthur version, that are a little off-putting. On the other hand, Silicon Vision has come up with a serviceable and accessible piece of software that is easy to understand and even easier to use.

If you already have ABC1 and are wondering whether to be content with the Dabs upgrade, then it is very likely that you will be satisfied, if you can live with ABC's greater limitations. Though most programs compiled with ABC are slower than those compiled with RiscBasic, they will still be running twice as fast as the equivalent Basic on average.

If you own neither, are looking for THE compiler to go for, and are confused about which one deserves to win the very public battle that has been raging in the advertisements, well my preference is for RiscBasic, but it is a very close thing.
ProductRiscBasic
SupplierSilicon Vision
 Signal House,
 Lyon Road, Harrow,
 Middx HA1 2AG.
Price£99.95 inc. VAT and p&p.
ProductABC2
SupplierDabs Press
 5 Victoria Lane,
 Whitefield,
 Manchester M25 6AL.
Price£99.95 inc. VAT and p&p