home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaDemoCD2.iso / ASCII / TEXTE / c.s.a.reviews / software / programmer / GFABasic < prev    next >
Encoding:
Internet Message Format  |  1994-06-02  |  18.5 KB

  1. From: honp9@menudo.uh.edu (Jason L. Tibbitts III)
  2. Subject: REVIEW: GFA BASIC v3.5
  3. Followup-To: comp.sys.amiga.programmer
  4. Keywords: programming, BASIC, compiler
  5. Organization: Blob Shop Programmers
  6. Reply-To: clcp16@vaxa.strath.ac.uk (Stewart C. Russell)
  7.  
  8. GFA BASIC 3.5 is a fast BASIC interpreter, with advanced commands which
  9. include matrix manipulation and direct access to the Exec, Intuition, Dos,
  10. and Graphics libraries.  The optional compiler generates code which is
  11. comparable in execution speed to a good C compiler.
  12.  
  13.  
  14. *** Statement of Interest ***
  15.         I have no commercial links with any part of the GFA organisation.
  16.         I have written several tutorial articles on GFA BASIC in Jeff
  17.         Walker's Just Amiga Monthly (JAM) magazine, the UK's only non-games
  18.         Amiga magazine.  I have never received any incentive, financial or
  19.         otherwise, to write about GFA BASIC; I paid cash for my GFA system.
  20.  
  21.  
  22. *** Product Preamble ***
  23. Product: GFA BASIC 3.5 Interpreter
  24.          GFA BASIC 3.5 Compiler
  25.  
  26. Supplier:       GFA Data Media (UK) Ltd
  27.                 Box 121
  28.                 Wokingham
  29.                 Berkshire
  30.                 RG11 1FA
  31.                 England
  32.  
  33. Price:          Interpreter #49.95 Sterling
  34.                 Compiler    #29.95    "
  35.  
  36. Those hashes are pound signs, btw; ASCII doesn't support them.  I have
  37. tried to find the suppliers outside the UK, but have received no answers
  38. yet.  The product is advertised in Amiga World, discounted to around $85
  39. (for the Interpreter, I assume) and one of the advertisements suggests that
  40. the US distributor is Antic.
  41.  
  42.  
  43. *** Reviewer Info ***
  44.                         Stewart C. Russell
  45. Paper Mail Address:     140 Capelrig Road
  46.                         Newton Mearns
  47.                         Glasgow G77 6LA
  48.                         Scotland
  49.  
  50. Telephone:              041-639 5372 (in UK)
  51.  
  52. E-Mail:                 clcp16@vaxa.strath.ac.uk
  53.         (This account should be active until July, when I graduate.)
  54.  
  55.                         scruss@cix.compulink.co.uk
  56.         (This is my "professional" account.  I get charged for any
  57.          international mail I receive or send, so use only as a last resort.)
  58.  
  59. [Ed. note:  Mr. Russel has informed me that he can forward any queries to
  60. Les Player, the MD of GFA Data Media (UK) Ltd.  I prefer not to give
  61. Mr. Player's address publicly.]
  62.  
  63.  
  64.  
  65. AmigaBASIC isn't one of the world's marvels of high speed execution.  It
  66. also get bored with the tedium of running your programs sometimes, and
  67. wanders off into oblivion.
  68.  
  69. The first version of GFA BASIC I saw (v3.041) was fast, but was so bug
  70. ridden as to be completely useless.  In a way, it was like the first release
  71. of the Amiga's operating system; it had something special, but the bugs
  72. made it less than useful.  And now the bugs are (mostly) gone, people
  73. remember it as it used to be - unstable.
  74.  
  75. GFA BASIC has been long in development, originally appearing on the Atari
  76. ST around 1986.  There is still the lingering feeling that, although the
  77. authors are clearly excellent programmers, they are still not 100% sure of
  78. the Amiga.
  79.  
  80. What you get
  81. ------------
  82.  
  83. There are at least 300 commands in GFA BASIC, ranging from bit operations
  84. to a file requester.  Most of the inch-thick manual is given over to command
  85. descriptions, with very small program fragments illustrating command usage.
  86. There is no tutorial in the manual, and the lack of properly commented
  87. examples (they are commented - but in German) is worrying.  The manual
  88. suffers from truly appalling translation in places, which can range from
  89. the faintly amusing to the downright misleading.
  90.  
  91. The GFA BASIC 3.5 interpreter is some 135 KB in length, allowing it to run
  92. comfortably on a basic A500.  Only one program can be edited at a time, but
  93. multiple interpreters can be run.  When this is done, blocks of text can be
  94. cut from one interpreter and pasted to another.
  95.  
  96. A shorter run-only interpreter is also supplied, and this may be freely
  97. distributed with your programs.  This program only accepts tokenised GFA
  98. BASIC files, and consequently could never be used for program development.
  99.  
  100. The Front End
  101. -------------
  102.  
  103. The single-bitplane editor screen has two rows of ten gadgets along the
  104. top, with a clock and a line number indicator on the right hand side.  These
  105. gadgets allow various file operations (Load, Save, etc) and edit operations
  106. (Block, Find, etc).  These gadgets correspond to function and Shift-function
  107. key combinations.
  108.  
  109. A couple of these gadgets merit special mention.  The Test gadget tests the
  110. integrity of your program's flow control structures, and warns you of any
  111. problems.  The Direct gadget drops you into a command line, where BASIC
  112. commands are executed as you type.  You should be able to work out what the
  113. Run gadget does.
  114.  
  115. The GFA editor is rather strange.  It parses the input line when you press
  116. Return, and won't let you continue if there is a syntax error.  It also does
  117. not allow blank lines, insisting on an apostrophe at the least.  You'll hate
  118. it at first, but when you realise that it allows abbreviated input (p for
  119. PRINT, inp for INPUT) and automatically indents loop structures, you'll
  120. begin to like it more.  Only one command is allowed per line, and line
  121. numbers must not be used.  In line comments are allowed though, but these
  122. must be prefixed with an exclamation mark.
  123.  
  124. Functions & Features
  125. --------------------
  126.  
  127. GFA BASIC knows about most of the commands in the Intuition, Dos, Exec,
  128. Layers, Diskfont Graphics and Icon libraries, and parses them
  129. appropriately; typing in "a%=allocremember(...)" for example would result
  130. in "a%=AllocRemember(...)" being returned.  (The very pedantic would also
  131. note that a syntax error would be returned too; ellipsis is not a valid
  132. input to AllocRemember()... :-) )
  133.  
  134. If your favourite routines exist in another library, you can use the FD
  135. file to create the basis for a stub.  I've already used this to create
  136. interfaces for the iff.library (for IFF handling) and the medplayer.library
  137. (for playing MED modules).  In this respect, being able to call these
  138. library functions from an interpreted language makes GFA BASIC a great
  139. prototyping tool.
  140.  
  141. As with most modern BASICs, GFA supports SELECT...CASE structures, and
  142. ELSEIF clauses in IF structures.  All structures support an EXIT IF clause,
  143. which works similarly to "break" in C.
  144.  
  145. INC, DEC, ADD, SUB, MUL and DIV manipulate variables far more quickly than
  146. the more usual infix operators.  Bitwise operators exist which are similar
  147. to (when compiled, identical to) 68000 instructions.
  148.  
  149. Windows and Screens are handled well, with HAM and Halfbrite as accessible
  150. as in any other language.  All the Window/IDCMP flags are available too.
  151.  
  152. Graphics commands are slightly better than AmigaBASIC's offerings; the DRAW
  153. command contains a full turtle graphics package, based on HPGL.  A slight
  154. nasty is the DISPLAY command; this is a hangover from the Atari, where it's
  155. quite safe to switch off Display DMA.  DISPLAY on the Amiga results in
  156. horrific flickering and all-over nastiness; avoid.
  157.  
  158. Two useful hangovers from the Atari are ALERT and FILESELECT.  ALERT creates
  159. a small requester similar to the GEM Dialog box, and nothing like as
  160. frightening as an Intuition red Alert().  FILESELECT creates a usable file
  161. selector; it's not as good as the ARP one, but it works well.  ALERT and
  162. FILESELECT are not Requesters, so they don't need a window to be attached
  163. to.
  164.  
  165. Arrays are used in the way that BASIC originally intended; as matrices.
  166. Matrices can be added, subtracted, multiplied, inverted, transposed, copied
  167. (in whole or part, with optional transposition) and the determinant and
  168. rank obtained.  Matrix housekeeping tasks for storing, recalling and
  169. printing matrices are supplied; a reasonable package.
  170.  
  171. Arrays can also have members inserted, deleted or moved, so dynamic list
  172. handling is a possibility.  Hardcoded quicksort and shellsort routines
  173. (fast) mean that the old bubble sort routine you've trusted since your PET
  174. days can finally be put out to grass.
  175.  
  176. Sound handling is OK.  I rarely use it though.
  177.  
  178. Variable Types
  179. --------------
  180.  
  181. The standard GFA integer is 32 bits long, unlike AmigaBASIC's sixteen which
  182. corresponds to GFA's Word type.  The byte variable type is unique to GFA
  183. BASIC, being identical to C's unsigned char type.  The Boolean type uses
  184. only one bit per entry if used in an array, or one byte otherwise.
  185.  
  186. This would be fine if GFA hadn't chosen non-standard suffixes for its
  187. variables.  A table shows the problem -
  188.  
  189.                                              Suffix
  190.  Variable Type                  Microsoft               GFA
  191.  =============                  =========               ===
  192.  Boolean                        (not supported)         !
  193.  8-bit Integer                  (not supported)         |
  194.  16-bit Integer                 %                       &
  195.  32-bit Integer                 &                       %
  196.  Single Precision FP            !                       (not supported)
  197.  Double Precision FP            #                       #
  198.  String                         $                       $
  199.  
  200. GFA's mathematical routines use a proprietary double precision format as
  201. the default variable type.  It is very fast (see the benchmarks later on)
  202. but unfortunately does not take advantage of a 68881/68882 coprocessor,
  203. since it was originally developed on the Atari ST.
  204.  
  205. Pointers are handled quite well for a BASIC, but not with the flexibility
  206. of C.  Memory access is enhanced too; the {...} operator can be used to read
  207. and write different types of variable.  Thus
  208.  
  209.   rp%={WINDOW(0)+50}    could return the address of a window's Rastport
  210.                         structure, and
  211.  
  212.   CHAR{attr%+8}="diamond.font"  could put a zero terminated font name into
  213.                                 a pre-prepared TextAttr structure.
  214.  
  215. Although structures aren't directly supported, they can be fudged using
  216. Malloc() and the {..} operator.  This is not C, after all.
  217.  
  218. (In)Compatibility
  219. -----------------
  220.  
  221. GFA BASIC is compatible with, well, only GFA BASIC I guess.  ASCII files can
  222. be merged into the editor, and anything that isn't understood gets `==>'
  223. placed in front of it.  Screen and window commands differ greatly from
  224. AmigaBASIC, but file handling and OBJECT (Bob) commands are almost
  225. identical.  Sprites, however, merit a separate command.
  226.  
  227. Major differences between Amiga and GFA BASIC include -
  228.  
  229.  - "IF...THEN...END IF" is written "IF...ENDIF" (THEN being optional).
  230.  
  231.  - "GOSUB name" branches to "PROCEDURE name".  Subroutines can have
  232.    parameters, and can be recursive; SUB...STATIC does not exist.
  233.    Procedures can be folded down to one line by hitting the Help key.
  234.  
  235.  - "DEF FNname(a,b)" becomes "DEFFN name(a,b)".  Multiline recursive
  236.    functions can be defined using FUNCTION, and can be folded using the
  237.    Help key.  Functions can be voided using "VOID func" or "~func".
  238.  
  239.  - Menu and Interrupt handling is wildly different, and is unfortunately
  240.    identical with the Atari ST's system, which busy waits on signals.  It is
  241.    possible, however, to interrogate IDCMP directly and Wait() on the
  242.    message ports.
  243.  
  244. If portability is an issue to you, GFA BASIC is available on the Atari ST
  245. and PC, though the latter is still slightly buggy.  OS/2, Windows 3 and
  246. Unix (386) versions are said to be under development.  GFA BASIC 4 should be
  247. with us before the third quarter of 1991, according to Les Player of GFA
  248. Data Media (UK).
  249.  
  250. (I know of people who run the program on A3000 machines with no ill
  251. effects, and also on Fatter Agnus B2000s. Runs just fine on my A500 too.)
  252.  
  253. The Compiler
  254. ------------
  255.  
  256. The interpreter is fast, but if you want real speed you need the optional
  257. compiler.  The compiler and linker run from the CLI, but a Workbench
  258. graphical shell is provided.  Maybe it's just the way my machine is set up,
  259. but the GFA shell seldom works properly for me, and I always use the CLI.
  260.  
  261. The compiler only reads tokenised files, and produces a standard Metacomco
  262. object file ready for linkage.  The GFA linker "gl" is very minimal, and
  263. reads the GFA library and library index in a proprietary file format.
  264. External functions can be linked into GFA programs, and the compiler manual
  265. details how to do this.  The GFA library is also supplied in Metacomco
  266. format if you wish to use a different linker.
  267.  
  268. Compilation is quick; all of the benchmark test programs actually compiled
  269. in under two seconds.  Most of the time is spent in the linker, since it has
  270. about 150 KB of library to wade through.  All programs are compiled with
  271. code for Workbench and window opening; producing CLI programs requires the
  272. opening of a CON: (or "*") output file and using stream printing.
  273.  
  274. A large amount of optimisation is done by the compiler, but a good part of
  275. the manual is given over to optimisations that the programmer can include
  276. for better performance.  An example of this is integer multiplication; if
  277. you stick to 16-bit integers, you can set the compiler to use the 68000
  278. MULS instruction.
  279.  
  280. Verdict
  281. -------
  282.  
  283. I bought GFA BASIC 3.5 back in October, and have been using it on a daily
  284. basis since then.  If I prototype something using it, it often interprets
  285. fast enough to do the job.  If not, I compile it, and it's fast enough.  If I
  286. really needed extra speed, I'd link in assembly language subroutines.
  287.  
  288. GFA BASIC isn't bug free yet; but what large product is?  The interpreter
  289. must be 99.5% solid, and the compiled code has never crashed on me.  I trust
  290. it enough to be writing my undergraduate project with it.
  291.  
  292. If you get C sick, take a long hard look at GFA BASIC.
  293.  
  294.  
  295. Benchmarks
  296. ----------
  297. (These are at the end since not everyone might want to read them - SCR)
  298.  
  299. It's easy to say that GFA BASIC is fast, but exactly how fast can only be
  300. demonstrated by comparison with other languages.  HiSoft (Professional)
  301. BASIC is a popular integrated compiler system, and is broadly compatible
  302. with AmigaBASIC.  AmigaBASIC is packaged with every Amiga, and has the
  303. unique ability to run more slowly on a 16MHz 68020/68882 machine than a
  304. 7.1MHz 68000 machine.  DICE is Matt Dillon's C compiler, noted for its rapid
  305. compilation and efficient executables.
  306.  
  307. All times derived from the internal timer routines in each interpreter or
  308. compiler, and then rounded to the nearest quarter second.  Default compiler
  309. options were used in all cases.  The test machine was a 3MB A500/A590.
  310.  
  311. (If you ask me very, very nicely, and I happen to be in a good mood at the
  312. time (and not too busy either), I can send you the actual benchmark
  313. sources.  You'll have to give me a pretty good reason for wanting them
  314. though.)
  315.  
  316. CALC
  317.  
  318.         The old CALC benchmark; 5000 loops of two multiplications and
  319.         two divisions each.  Tests floating point speed and accuracy.  GFA
  320.         uses its own 64-bit floating point format, while HiSoft and
  321.         AmigaBASIC use single precision in this test.
  322.         (An IEEE Double Precision CALC using Matt Dillon's DICE is given
  323.         for comparison.  Out of the four different math packages, IEEE was
  324.         the only one to leave a residual error (of ~-5E-8).  Most odd.)
  325.  
  326.                 GFA     GFA
  327.         Interpreted     Compiled        HiSoft    AmigaBASIC    DICE
  328.         ============================================================
  329.  
  330. Run Time       5.0        3.0            3.25        16.75      6.5
  331. (seconds)
  332.  
  333. Compile Time   -         13.5            5.0          -        11.0
  334. (seconds)
  335.  
  336. Code Size      -         11184          19208         -         7592
  337. (bytes)
  338.  
  339.  
  340. I/O TEST
  341.  
  342.         A small (and not very stringent) test of my own devising.  `Write'
  343.         writes out the integers 1-10000 to a file in RAM:.  `Read' reads
  344.         them back again.  `Print' tests text output by printing 1000 lines
  345.         of 56 characters to the Workbench screen.
  346.         (The RAM: used here is not Commodore's, but The Other Guys'
  347.         Recoverable RAM Disk running FFS.)
  348.  
  349.                 GFA     GFA
  350.         Interpreted     Compiled        HiSoft          AmigaBASIC
  351.         ==========================================================
  352.  
  353. Run Time
  354. (seconds)
  355.  
  356.    Write      14.25      12.0           161.0              42.75
  357.     Read       7.75       7.0            20.25             49.75
  358.    Print      37.5       37.25           78.75            149.75
  359.  
  360. Compile Time   -         14.0             4.5               -
  361. (seconds)
  362.  
  363. Code Size      -         14496           23096              -
  364. (bytes)
  365.  
  366.  
  367. PCW
  368.  
  369.         A suite of benchmarks used many years ago by PCW Magazine to test
  370.         machine performance when running BASIC.
  371.  
  372.  PCW1 - FOR k=1 TO 10000:NEXT k, with k floating point
  373.  PCW2 - 10000 GOTOs and 10000 floating point additions
  374.  PCW3 - Floating Point divide, multiply, add, subtract; all 10000 times
  375.  PCW4 - Same as PCW3, but with explicit constants
  376.  PCW5 - PCW4 plus 10000 GOSUBs
  377.  PCW6 - PCW5 plus 10000 "FOR l=1 TO 5:NEXT l"
  378.  PCW7 - PCW6 with an array access in the FOR...NEXT loop
  379.  PCW8 - 10000 additions, exponentiations, LOG()s and SIN()s
  380.  
  381.                 GFA     GFA
  382.         Interpreted     Compiled        HiSoft          AmigaBASIC
  383.         ==========================================================
  384.  
  385. Run Time
  386. (seconds)
  387.  
  388.   PCW1         0.75       0.75           1.25               4.0
  389.   PCW2         2.75       0.5            2.5               21.5
  390.   PCW3         7.75       3.0            5.0               43.0
  391.   PCW4         7.5        1.25           5.5               48.0
  392.   PCW5         8.0        1.25           7.25              53.5
  393.   PCW6        13.25       4.0           14.25              90.75
  394.   PCW7        21.5        6.5           23.75             140.75
  395.   PCW8        34.25      29.5           20.75             179.75
  396.  
  397.  Average      12.0        5.75          10.0               72.75
  398.  
  399. Compile Time   -         16.0            6.5                -
  400. (seconds)
  401.  
  402. Code Size      -         15272           22944              -
  403. (bytes)
  404.  
  405.  
  406. SIEVE
  407.  
  408.         The Sieve of Eratosthenes with 5 loops of 7000 short integers each.
  409.         (The DICE benchmark is a slightly different program to the BASIC
  410.         ones, which used GOTO liberally.  The result is the same, though.)
  411.  
  412.                 GFA     GFA
  413.         Interpreted     Compiled        HiSoft    AmigaBASIC    DICE
  414.         ============================================================
  415.  
  416. Run Time      53.5        3.5            40.75      258.75      1.75
  417. (seconds)
  418.  
  419. Compile Time   -         17.0             4.5         -        11.0
  420. (seconds)
  421.  
  422. Code Size      -         11256           19256        -         5732
  423. (bytes)
  424.  
  425.  %*%* end *%*%
  426.  
  427. --
  428. |Stewart C. Russell       | University of Strathclyde, Glasgow, Scotland, UK|
  429. |clcp16@vaxa.strath.ac.uk |        (opinions my own, not theirs)            |
  430. |                Also known as scruss@cix.compulink.co.uk                   |
  431. |       "Beauty is truth, truth beauty" - Keats                             |
  432. |       "You lying get!" - The Living Carpets, Vic Reeves Big Night Out     |
  433.  
  434.