ACE: A Compiler for Everyone *

by David Benn, April 1994

* This article first appeared in a now-defunct electronic journal (Amiga Addicts). It was written prior to the current release of ACE and so comments re: development carried out since version 2.0 appear where appropriate.


Introduction

Around the middle of 1991 I was thinking about what would be a suitable next programming project. During the previous twelve months I had found myself becoming increasingly interested in programming language translation. This interest was sparked while studying a compiler writing subject in my second-to-last semester as an undergraduate.

By the end of that semester, I'd written a Pascal- compiler which produced p-codes for a hypothetical stack-based machine. Prior to this I had written a BASIC interpreter.

Both the compiler and the interpreter were targeted at the IBM PC and were written in Turbo Pascal. The interesting thing is that I approached the BASIC interpreter from a naive point of view.

Well, what I came up with was a big, ugly program that actually worked quite well as a BASIC interpreter (it supported graphics, sound, file I/O) but was slow and inelegant. It was also no better than anything else that was around at the time. But I had a great time writing it! I became obsessed with it for a few months. I still run it from Windows every so often for a chuckle.

However, the knowledge and experience I'd gained from both projects left me decidedly hooked on the notion of developing compilers and interpreters.

After finishing that Pascal- compiler I decided to take what I'd learned and apply it to the Amiga. I wrote a cut-down version of the LOGO programming language because I'd always loved (and still do) the idea of Turtle Graphics. Next I became interested in threaded interpreters as embodied by such languages as Forth. So, I became an avid follower of Forth for a time and wrote a version of that language for the Amiga.


Enter ACE

This was all good fun, but none of these interpreters or compilers could be used for serious programming. What I wanted was to develop a language that I could use myself for real work.

I had been programming in C for a couple of years by 1991 and was impressed by that language's simplicity, but annoyed at the amount of hard work required to produce even simple event-driven Amiga programs, due to the closeness to the operating system that was required.

Pascal and Modula-2 didn't really get you any further away from the operating system. BASIC did, but it was slow and perhaps even more importantly from my point of view, AmigaBASIC didn't let you produce standalone executables. You always needed the interpreter.

AmigaBASIC was slow, had a nasty editor, weird bugs and was generally temperamental. But, I got my start on the Amiga with BASIC when nothing else about the machine seemed familiar after my C64 days. And anyway, the language itself was quite nice. What was primarily needed was for programs to run faster and to be standalone.

Okay, I'd seen a BASIC compiler or two for the Amiga, but they cost money! :) I came across one free BASIC compiler called Cursor which had actually been written in AmigaBASIC (which I think is really neat). At that time, Cursor had a lot of features that weren't implemented *, although I was impressed with what had been done.

* A more recent (1994) version of Cursor has been rewritten in C and is much more complete.
In any case, I got to thinking how nice it would be to write my own compiler and how I could improve upon what had gone before.

So it was in September of 1991 that I started the process of designing what was to become ACE. The acronym A.C.E. has come to be associated with a number of things including:

The title of this article shows another possible meaning and indicates something of the spirit of the project.


Design Goals and Features

Now, after five releases (1.0, 1.01, 1.02, 1.1a, 2.0) of ACE as a freeware compiler - with another version expected soon - I can identify several design goals which have been most important to the development of ACE:

ACE satisfies each item on this list to some degree.

ACE is largely compatible with AmigaBASIC with relatively minor differences between the two languages. I am working to close the gap. Many programs will compile unchanged from AmigaBASIC (saved as ASCII text files) and many more require only small changes to compile under ACE.

ACE is known to be running on everything from an A1000 with 512K of RAM to an A4000 with 5 Megs of RAM. I personally develop and run ACE on an A500 * with a 52 Meg GVP hard drive and 5 Megs of RAM under Wb 2.04. Other people use everything from Wb 1.3 to 3.0.

* More recently, I have switched to an A1200 for development purposes.
ACE boasts around 200 commands and functions. Expression evaluation and built-in functions are almost identical to AmigaBASIC. Currently, ACE supports short and long integer, single-precision floating point and string data types.

ACE's high level of functionality can be seen by browsing through the online reference manual which accompanies it. There are many language constructs, commands and functions not found in AmigaBASIC, such as:

ACE has been used to write a wide variety of programs, from an 8SVX sound sample player to Neural Networks, a Simulation of Jupiter's Galilean Moons for any date and time, fractal graphics, games, shell utilities, communications programs, etc.

I have used ACE to develop a graphical front-end for ACE, called AIDE. This is included with the distribution.

The compiler produces programs which run (often much) faster than their interpreted counterparts. An average size for each executable is around 40K.

The language is extensible in three main ways:

Note: version 2.3 also allows for the creation of linkable subprogram library modules.
Of course, as in AmigaBASIC, machine code routines can be called directly after poking them into memory byte by byte. This is rarely necessary given the ability to call external functions from separately compiled or assembled C or assembly modules, a distinct advantage over AmigaBASIC.

Ease of use is an important factor. ACE can either be run from the shell or via AIDE (needs Wb 2.04 at least currently). A "bas" script automates the compile-assemble-link cycle when used from the shell. AIDE makes editing and compilation more pleasant via pull-down menus. Although ACE's compile-time error messages are probably no better than those of most compilers, they are generally comprehensible.

ACE produces assembly source code files which can be inspected as normal text files. A68K takes such a file and produces a machine code module. Blink links this object module with code from ACE's run-time libraries.

While not explicitly a "design goal", I have attempted to make ACE responsive to the needs of the people using the language. The inclusion of features such as a high-performance serial I/O capability (with support for multi-port serial cards) has been a direct response to the needs of users. This continues to be important as ACE develops further, but each new potential feature must be evaluated in light of the likelihood of its widespread use as well as in terms of the aims of the language. When a new feature is added it must be done in such a way as to be consistent with the existing models employed by the language (eg. the notion of channels is used for files and has also been used for serial I/O, etc) and the typical syntax of commands and functions.


The Future

There are many items on my "to-do" list for ACE. Future plans include:

and more.

The forthcoming version will include:

and many other features.

* All included in version 2.3
I am under some pressure to move away from Wb 1.3 as the baseline operating system version and to make 2.04 the baseline. This won't happen in the upcoming version (v2.3), but beyond that, I can't say. Trying to support Wb 1.3 and 2.x/3.x of AmigaOS means a significant amount of duplication of functionality in fairly minor ways, and a tendency to discount the use of interesting and useful features in more recent versions of the operating system.

The next release of ACE is scheduled for around the end of May 1994 (it was not actually released until late October).

ACE may become a shareware product at some stage, but the fee is unlikely to be more than $10 or $15.

Possibilities for versions of ACE beyond 2.3 include incorporating ideas from object-oriented and functional programming, and a new programming model more akin to the Amiga's underlying message-driven paradigm. The latter would be an alternative to the current event-trapping and menu/gadget waiting models found in ACE.

Conclusion

After more than two years of (part-time) development, ACE has become a worthwhile project with a significant number of people finding it to be a useful tool with which to create Amiga programs.

It is a venture which is still able to enthuse me and I see plenty of scope for further improvement and additions.


How to obtain ACE

ACE v2.0 and AmigaGuide versions of the ACE v2.0 docs are available (now v2.3, complete with AmigaGuide docs):


Contacting the Author

I am reachable via e-mail:

	Internet:       D.Benn@appcomp.utas.edu.au
	Compuserve:     100033,605
or via snail-mail:

	181 St John Street, Launceston, Tasmania, 7250, Australia.
or by phone:

	(003) 317 680 [home]
	(003) 243 529 [work]
In addition, there is now an Internet discussion list dedicated to ACE.

To subscribe to the list, send e-mail to:

	Listserver@appcomp.utas.edu.au
The message should contain one line of the following form:

	subscribe ace FirstName LastName

References

D. Benn, 1994, ACE Programmer's Guide
D. Benn, 1994, ACE Language Reference