Commodore User
1st July 1985
Categories: Review: Software
Author: Brian Grainger
Publisher: Melbourne House
Machine: Commodore 64
Published in Commodore User #22
Watch Your Language: Alternatives To Basic On The C64
Nearly all home computers have the Basic language built into them as standard, and the Commodore 64 is no exception. But that doesn't mean you're stuck with Pokes and GOSUBs. There's a wealth of other languages just waiting to be explored. We've rounded up the most recent implementations of Forth, Pascal and COMAL - all readily available for the C64.
Forth is a high-level programming language like Basic, which has become the only real alternative to Basic and Assembler on both the Vic-20 and Commodore 64. It's 'compiled' rather than 'interpreted' and allows users to define their own commands, functions and procedures. It also approaches machine-code in execution speed. Originally designed to be a 'fourth-generation' language (hence the name), it never quite made it, despite being easy to use for beginners.
Pascal is probably the most popular programming language around, next to Basic. But it has confined itself more to generating professional and business software. It's a 'compiled' language, so it runs much faster than interpreted Basic. Pascal (named after the mathematician Blaise Pascal) is often described as an 'elegant' language because it encourages a systematic and discipline approach to programming.
COMAL is an acronym for 'common algorithmic language'. That phrase itself suggest that this is a highly structured programming language. COMAL is easy to use and provides listings that are far more comprehensible than Basic. Although it's been around for at least fifteen years, it's remained largely unheralded. Until recently, only 'public domain' versions of COMAL were available.
Forth
The latest version of Forth on the Commodore 64 comes from Melbourne House. It's called Forth+ and comes on cassette for £14.95. A nice touch is that Pavloda Fast-loading is included, so you're up and running in around two minutes. But once loaded, a few simple keystrokes convert it to disk orientation.
A 36 page pocket-sized manual is provided which covers the major aspects of the implementation reasonably well. As usual it is not a tutorial in Forth - and you'll probably need reference books if you're a beginner. Over half the manual is devoted to a reference guide of the standard FIG dictionary. The rest covers the specialities of this version which really make it different from other versions.
There are two main departures from the FIG standard both of which make use of features for which the C64 is renowned. Historically most Forth systems have treated disk storage as virtual memory, loading blocks of source code into RAM and "forgetting" them when done. In this way large applications could run economically not grabbing huge chunks of memory as they go.
The C64 as we know from the Advertising Standards people has a jumbo-sized memory. Forth+ makes use of this feature instead of referencing disk or tape continually. Thus, tape users are not bedevilled by extraordinary loading times or where on tape block 25 may be. Furthermore, when a program has been debugged it may be saved as just that, re-loaded and run by a SYS command without even the need to re-load the Forth operating system each time. What a splendid way to write and save programs!
In addition, your programming is made easier because you can actually forget all those hundreds of POKEs needed to create music, sprites, graphics, etc. These are all pre-defined as Forth+ words that only need you to specify the parameters. There are INK, BORDER, HRG (for high resolution graphics) PLOT, sprite defining and moving words, FREQ PULSE and many more. Games enthusiasts may even use JOYSTICK and PADDLE!
For the really dedicated there is the Forth Assembler. Beginners beware. This needs a full understanding of Forth and 6502 Assembly Language, but (although I have never actually put it into practice) should allow you with relative ease to mix high level Forth and machine-code routines for that extra speed and gloss.
After a little time with the C64, I found just about everything checks out. Like any new operating system, it takes a little time to get used to it. After that, I reckon that with Forth+ I was as near to heaven as I have been for many a moon. My only problem, unsolved because I had too little time, was that I could not open any files to other devices. I suspect that invoking Kernal routines could be the way to do it, but, as said, with care.
As a bonus a game is also provided on the tape which will give some hints on how to use Forth+. To play it, though, you'll need a joystick.
This version of Forth is more attuned to the C64 than any other I have seen. For what is certainly a superior operating system than the resident Basic (I am biased - so what?) including syntax error trapping, compiled speed, assembly language and access to C64 sound and graphics. At £14.95, can you afford to ignore such an offer?
Pascal 64
Of the many languages developed that rectify the niggling faults in Basic, Pascal has recently become the most popular. There are several versions around on the C64, but the most recent is Pascal 64 from First Publishing. It's a disk-base compiler costing £34.95.
Most C64 compilers are disk-based as they tend to be pretty big; 16K to 32K typically and this would leave little RAM for the programs and machine-code produced by the compiler.
Pascal 64 employs some protection method that cause it to misload quite frequently - at least my copy did. I started by reading the manual several times and had high expectations but as I tested it, several errors arose and I became somewhat disillusioned.
The first problem I encountered was that the command to load the compiler kept on coming up with "? FILE NOT FOUND ERROR". An examination of the directory showed that a LOAD"BOOT",8 was needed, not what the manual said.
Having programmed in Pascal for several years now I was surprised to find that several test programs I entered all gave syntax errors. The fault lay with the compiler in that it had to have all identifiers (keywords and operators) separated by spaces - even a space between WRITELN and (I) in the statement WRITELN (I). Normal Pascal is not quite so strict.
Two words can be used to describe Pascal 64: user unfriendly. The whole process of editing and running the program involves the following process:
- Load up program
- Change it
- Save to disk
- Load compiles (one minute) the compile program to disk
- Load LOADER program and run it to load compiled code from disk
- Run or save machine-code
Depending on the size of your program this can take from two to five minutes to do. If by accident you type in the wrong name to the compiler then it bombs out with a "FILE NOT FOUND ERROR" and has to be reloaded.
The Pascal syntax is a little unusual in places but anyone who learnt with a compiler should have little trouble moving onto others. The range of extensions to allow Commodore 64 facilities is not bad - these include string handling, sprites, poke and peek and graphics, plus an interrupt facility. It would be nice if it could also include inline machine code.
My impression of the compiler is that it is a pretty good piece of software but the authors have never let anyone else test it out. Certainly most English programmers put a space between PROGRAM and NAME in input prompts, but that is a minor quibble. More attention should have been paid to tidying up the 'front end' of the program and how it is used. In addition I would like to see a few big example programs included in the disk.
Despite the flaws in the software, the manual is an impressive 50-page ring-bound affair. It explains how the compiler works and then gives a comprehensive overview of Pascal, its syntax, variables, maths operators, structures et al. The whole lot is interspersed with small programmed examples.
This is generally a good product but it's spoilt by a few errors and general unfriendliness. The code produced runs pretty fast and the ability to PEEK and POKE and SYS machine code means that this can be used to produce fast games and utilities. If a revised edition is brought out with these points attended to then I can happily recommend it.
COMAL
COMAL has its origins in Denmark in the early 1970s. Borge Christensen found his students were writing Basic programs that were difficult to understand, debug and maintain. Having read the ideas of Niklaus Wirth, the inventor of Pascal, Christensen collaborated with Benedict Loefstedt to improve on Basic. Its use in education meant that the new language had to be easy to use like Basic, but powerful like Pascal. The result was COMAL, Common Algorithmic Language. So now you know.
COMAL is now the recommended programming language for education in Denmark, Sweden, Eire and from 1986, Scotland, COMAL has developed quietly over the last four years. Its progress was monitored by International representatives of the users and industry and in 1982 a standard, called the COMAL Kernal, was finalised.
In December 1983 it was announced to the world. Since 1983 the COMAL cartridge for the Commodore 64 has been used by selected people to eliminate the bugs and suggest improvements.
COMAL is available on a cartridge for the C64. It costs £49.99 and comes complete with 320-page manual and demonstration disk. It's currently available from ICPUG - more details later. With the inbuilt enhancements to allow each use of the facilities of the Commodore 64, the cartridge turns the C64 into the most powerful home computer. It can access 152K bytes of memory with a future expansion of an extra 32K catered for.
COMAL's ease of use is shown by its editing environment, which includes the following: AUTO, RENUM, FIND and CHANGE. Lines are checked for syntax errors on entry. Sections of programs can easily be listed to printers, disks or cassettes.
Routines stored on disk or cassette can be merged into user programs without the worry about overwriting existing lines. Programming niceties, such as line indenting to highlight program structures, is catered for automatically, unlike Pascal where the user must do it himself.
COMAL caters for the following program structures:
- IF...THEN...ELIF...ELSE...ENDIF
- CASE...OF...WHEN...OTHERWISE...ENDCASE
- REPEAT...UNTIL
- WHILE...DO...ENDWHILE
- FOR...TO...STEP...DO...ENDFOR
- LOOP...EXIT...EXT WHEN...ENDLOOP
An error handler structure is available for the programmer to trap errors or create his own error handling routines:
TRAP . . HANDLER . . ENDTRAP
The user can also define functions and procedures with two-way parameter passing and local variables.
The COMAL cartridge enhances the COMAL Kernal with eleven packages including commands to control paddles, joysticks and lightpens, plot high resolution graphics, define and control sprites, and play music. It also provides interrupt driven sprite movement for animation and interrupt-driven playing of music.
A speciality of COMAL for the C64 is the ability to do Turtle graphics. Many of the commands of Commodore LOGO are implemented in the Turtle package so providing two Educational languages for the price of one. Special commands to support windowing techniques, WINDOW and VIEWPORT are available for business applications.
To put the icing on the cake, there are a number of utilities:
- dump text or graphic screens to a printer, cassette or disk
- load text or graphic screens from cassette or disk
- redefine character sets
- function key defined on start-up to commonly used commands
- redefine function keys
- write COMAL routines in machine language and link into COMAL to form part of the language
- spare ROM socket provided in the cartridge for the user to add such routines in EPROM
To sum up, COMAL is a language that suits educational needs, while at the same time providing facilities for commercial applications and games creation. This cartridge is a must for COMAL addicts.
Other Reviews Of Forth+ For The Commodore 64
Forth+ (Melbourne House)
A review by A.W. (Home Computing Weekly)