Scott Ballantyne: Blazin' Into Forth

Originally published in Commodore Hacking electronic magazine #15, April 1998

In the early 70’s, Charles Moore designed one of the most powerful computing languages known. This language, Forth, was very different from the traditional procedural languages.

Forth is a language which allows the programmer to change most any facet of the language they wish ( including syntax extensions ).

Forth’s rapid acceptance on 8-bit microcomputers stemmed from the fact that it took a relatively small amount of memory to properly implement the language.

As the 1980’s were reaching their final years, Scott Ballantyne released an implementation of Forth for the Commodore 64 known as Blazin’ Forth ( herein referred to as BForth ).

Many were surprised at how powerful BForth was. The biggest surprise was that Scott gave BForth away for free. While many commercial Forth implementations graced the market, Scott came out of nowhere and blew them away with a superior implementation of Forth.

Scott was gracious enough to grant the following interview via e-mail.


What influenced you ( during a time when Pascal and C were making big press ) to write a Forth compiler?

I’ve always hated Pascal - the language is too restrictive to be useful with all that strict typing, and the I/O primitives are a disaster. I don’t like languages that feel like a straight jacket, I prefer spandex. I wanted a fast, interpreted language to fiddle with the C64’s metal, write communications programs and play with the SID chip and do graphics programming, etc. I actually thought about writing a C interpreter, C is fun and a great language but with all the libraries you need to make it useful (stdio, IO primitives etc.), I was afraid it would be too big to do anything useful. The C64 disk drives were too slow to make compiling reasonable and interpreters are more fun anyway, so it had to be an interpreter.

At the same time I was thinking about writing an interpreter I was trying to learn Forth. My background is mostly in Lisp, and that’s still my favorite language (Scheme, actually is my favorite). I would have written a Lisp interpreter but I’d been there, done that and I’d heard about Forth for years - robotics has always been an interest of mine and Forth is used a lot for that, so I bought some of the Forth programs that were available for the C64. What a rip off those were! They just crawled, not to mention that they were riddled with bugs - really horrible bugs like incorrect multiplication and division routines. They also didn’t have some of the really clever Forth features like does>, and absolutely no programmer friendly tools like a trace or watchpoint. Not to mention no code to study, no extension to study, they were really poor. I kept buying these cartridges hoping to find one that was usable and they kept making me madder and madder, so I finally decided if I wanted to learn Forth, I would have to write my own.

I assume from your references to Henry Laxen and Forth Dimensions that you had prior experience with Forth?

Not really - as you see above. I ordered all the back issues of Forth dimensions that I could, since I wanted to do things right and that seemed to be the way to understand things. I got a lot of documents about Forth-79, Forth-83 and etc. Halfway through the writing of the Blazin’ Forth, I heard about Laxen’s compiler, got a copy of it and I learned a lot from it. The way the block buffers are implemented, in particular, are modeled on the way Laxen did things. That’s a very clean, very nice piece of work. I admired that compiler a lot. But Blazin’ Forth is a lot different. I admire clean code and beautiful designs, but you always have to remember the old saw: “If you make it fast and ugly, people will hate you. If you make it beautiful but slow, nobody will use it.” So there’s a tradeoff one often has to make, especially on a small machine like the 64. Not to say that BForth is ugly, you understand, you just wouldn’t take it home to momma.

In building BForth, you had put together a complete Forth-83 implementation with snazzy extensions. What led you to make the package free-for-use rather than trying to make a commercial go of it?

I thought about marketing it. I probably could have made quite a bit from it, but I was still simmering from all the money I’d spent on those awful implementations in the cartridges. Remember that part of my motivation here was revenge. Also, around that time Stallman had just announced the GNU project. Having been at MIT and immersed in what later came to be called the hacker culture gave me a desire to encourage that sort of thing in general, and specifically on the 64. Why not? So I took the GNU manifesto and wrote this gigantic legal document based on the manifesto and gave the whole mess away for free. Besides, it’s a lot more fun creating something than it is selling it, and I wasn’t sure I wanted to spend years supporting any one piece of software, which I would have felt duty bound to do if I sold the thing. There were other projects I wanted to go on to. There were a lot of reasons, some idealistic and some just plain selfish.

In the documentation accompanying BForth, a reference is made to a version for the Commodore 128 supporting a number of features including multitasking. Did this project ever see the light of day?

Actually, the 64 version was multitasking originally. There wasn’t enough room to support that and the rest of the stuff (like the sound and graphics words) so I took it out. I think it was a mistake to axe the U area like I did, though. If I hadn’t done that, some people could have written a tasker on top of what I gave them. Not a gigantic mistake, but it would have been better if I left it in. Remember that the traditional Forth multitasking is cooperative. Not sure I agree with that…

I bought a 128, actually I just sold it a couple of years ago. Right around the time I was getting around to writing a Forth for it the Amiga came out and just blew me away. I never got back to the 128. The Amiga was great - what a shame that it was so poorly marketed. I worked on the ARP project and a lot of that code made it into the Amiga operating system, which was gratifying. Also, Commodore did pay us for that work, although it started out as another free project. I worked on that with a guy named Charly Heath. We never met - I could sit across the table from Cheath (that’s what I called him) and never know it, all the work was done over the net. We were in daily contact and Cheath was a great programmer, also a very nice guy. It was interesting, but getting close to Commodore at that particular time was not the best thing. To tell you the truth it made me ill, there was a lot of ugly politics and bad decision making at the time, so I lost interest in doing stuff for people on the Amiga. I still have an Amiga though. I wrote an interesting operating system for it based on Lisp. It’s like an Amiga Lisp machine, it acts a lot like the original Lisp machine, if you ever saw it. I have a good chunk of a Smalltalk programming system written on it too - graphics interface and everything. Really cool. Every now and then I pull it out and fiddle with it. I never released any of this code and then the company collapsed and there went my motivation to polish it up. I don’t mind rough edges, but when I release something I want it to be as close to perfect as possible.

There are a lot of Amigoids out there watching what VisCorp will do now that they own the rights to the Amiga. Is there a chance that your Lisp and Smalltalk will see the light of day for this die-hard group of Amiga fanatics?

I suppose it’s possible. I only have a 2000 - it has a 68020 card with 2 megs of memory, but I sort of feel like with the 3000-4000 people wouldn’t be that interested in code that was developed on the 2000, also the new graphics modes that are available on the later machines I don’t have. Maybe I’m wrong. Doing this interview has got me interested in it again, I worked on the small talk stuff this weekend, as a matter of fact. Who knows?

What tools did you use to develop BForth? ( A metacompiler or pure assembler? )

I wrote my own assembler and linker. The assembler looked a lot like Lisp, the linker was very primitive really, just ran through and resolved references, it couldn’t really move stuff around like a real linker can. It did make a cross reference though.. The assembler was actually rather nice. Some people wanted it, but I never got around to polishing it up and documenting it to release it.

I have never been taken with the Forth metacompilers, but perhaps I don’t understand them enough.

What sort of feedback did you receive from the general public pertaining to your compiler?

Well, it was great. I was amazed. I thought maybe 10 people in the world would be interested in a Forth compiler. I had a Compuserve account back then and it was first uploaded to the C64 forum there, along with the source for the higher level words and all the documentation. It was quite a lot. It took forver for the sysops to make it public - nobody said anything but I think they were checking around to make sure I hadn’t ripped it off. I guess it was a pretty unheard of thing to do, just give away a major piece of software like that. Anyway, once it was released the response was fantastic - it ripped across the country and I got tons of mail. I’ve never received so much mail from people. The most satisfying mail was from Forth programmers who said things like “I took my Forth cartridge out in the yard and drove a knife through it”. Revenge. It’s so sweet…

And people sent me presents - some guys in California figured out how to make a self booting cartridge out of it and sent me a Blazin’ Forth self bootable cartridge. That was really nice. There were even some commercial products based on it - you could do a save-Forth and lock people out of the Forth system, so it just looked like an application. There was a communications program, and some kind of cad system. I have no idea how well they did, but the programmers sent me complimentary copies.

Some kid at CMU wrote a VAX Forth compiler based on BForth for a dissertation and sent me a tape and a printout. I kept it here for a long time, but I don’t own a VAX and eventually got rid of it. I got BForth tshirts and of course millions and millions of questions.

I got some hate mail too.

What sort of hate-mail?

The sort you always get. I got some from libertarians who I had offended by giving it away, I got some from people who hated Forth and thought I should have written something else, I got some from people who had downloaded it and couldn’t make it work. I’d try to help them, but sometimes it just didn’t work for them. In many cases I had no idea why, they couldn’t tell me, just `it didn’t work’. I never got any mail from people who had written Forth’s for commercial use - I was surprised at that.

I’ve seen nearly constant battles on net conferences between the Forth camp and the Pascal/Modula camp. Did you encounter any “language bigots” in the early days of BForth?

Oh sure, you always do. Frankly I think all these language wars are misguided. I hate Pascal, but I don’t have a problem if you use it. Why should I? I’ve never understood that. There are languages which are too brain dead to be taken seriously, but I still don’t have a problem if people want to use them. I think it must be either not enough to do, or some kind of insecurity.

What positive feedback did you receive about BForth?

People wrote tons of really useful software in it and I got copies of all of it.

The nice thing too was that there were so few bug reports. Actually, there was only one bug ever reported from Blazin’ Forth, and I found that myself and uploaded a patch. To tell the truth, there is one other bug in that program, I discovered it years later. It’s actually a bug in the assembler - there was a garbage line that should have triggered an error but didn’t, it assembled garbage. But the nature of the bug is such that it actually is only triggered extremely rarely. No one has ever reported it. Hehe!

And this is an interesting point: I learned a lot from writing that thing and one of the things I learned was the value of programmers being involved in every aspect, from design to coding to writing the manuals to testing. Writing the manuals not only uncovered a lot of bugs as I was thinking up examples, it also suggested various improvements. But the biggest applause has to go to my girlfriend - we are still together, incidentally. She’s the greatest. She’s a musician and was curious about all this computer stuff, and remember that I wanted people to be able to learn Forth from scratch - the documentation, everything was designed to make it possible and easy to learn Forth from Brodies book, which was the most common text.

So I gave her the Forth compiler, the documentation and the Brodie book, and she taught herself Forth. She found tons of bugs, but when she was done, she had learned Forth, I had a debugged system and I was pretty pleased, all in all. I’m sure this is one of the reason that people liked it so much - I got a lot of mail from people who said “I’ve tried so many times to learn this language, and now I have.”

There was lots more stuff - I got pictures of people holding up signs that said “We Love Blazin Forth!”. It was very gratifying. Much nicer than money. People were very appreciative and tried to show it.

Would you recommend Forth as a first computer language?

I think any modern computer language is a good one. Forth would be good. A lot of teaching beginners has to do with language independent features such as feedback and debuggers and stuff. It’s not very rewarding for most first timers to do !’s and @’s or write ‘hello world’ programs. Big deal. That’s one reason I put the turtle graphics into BForth - you can see loops and larger structures, it makes sense and it’s rewarding, so I’m a big supporter of that sort of thing for beginning programming. I still remain partial to the Lisp class of languages, so if I were teaching I would probably use those for a beginner, but the same comments apply to those.

If you could do anything differently in the development and distribution of BForth, what would you do?

Oh, I made some mistakes. I should have preserved the U area, like I said before. Today I would probably not implement the Forth block system, I’d use files instead. I never liked that, to tell the truth. It made a certain sense with the 64 disk drives, and the code I wrote is optimized for the rotational speed of those things, but I think it leads to better programming to just store your code in a file with a name. I would have added more hooks, I think I would have added a ‘junk’ dictionary for things like defining words or the assembler and editor that you could make ‘go away’ once you were done. That would have saved a lot of memory, I think.

You always think about stuff like this for all your projects. Software is never really finished and I could go on forever about just about every program I’ve ever written. Even about little things. For example, I really regret not special casing horizontal and vertical lines in the graphics line drawing function. A little thing, but it was a mistake and it urks me. I thought about it at the time, but the compiler was getting so big, but I still think it was a mistake. Just last week, I was working on some medical imaging system software and I was writing a line drawing function, and I special cased the horizontal and vertical lines, and guess what I thought: “Shoot - I wish I’d done that with that Forth compiler…”

What sort of work are you doing nowadays?

Whatever interests me. I have my own company “ScotSoft Research” and I do pretty interesting work for which I charge. A lot of Unix work, custom applications, kernel enhancements, etc. I have donated a lot of code to the GNU project and still admire what they do, and I still love to write software. For my own pleasure and improvement I still have lots of projects. At some point I’ll finish my Smalltalk system for Unix computers. In a lot of ways the Amiga version is better - there’s a lot to be said for taking over the machine. Maybe I’m a control freak, but there’s a real rush in writing something ‘from the metal up’. You can’t do that with a Unix box and expect people to use it.

Still, I like Unix a lot. The computers I’ve bought for my company are all Suns. IBMPCs and MACs make me puke. The Amiga, as good as it was, would have been a better machine if it had paid more attention to Unix…

Is Forth still something that you use on a regular basis?

Nope. Haven’t used Forth in years, except for the odd command at a the Sun monitor prompt. That’s more a reflection on the environment I work in these days than Forth. It’s a shame that the Forth community has let itself become so insular - you would have Forth compilers on Unix machines if there had been standardized support for libraries and a file system. Another weakness of forth is the lack of ‘struct’ - of course that can be implemented, but it needs to be part of the language definition to be truly useful.

I still think Forth is great - I look at those micromint projects sometimes and think it would be fun to do some of that stuff in Forth…

Was the C64 the first home computer you owned?

Sure was. The low cost + 64k memory and extra features made it an inevitable addition to my household :-)

Describe your introduction to programming ( were you a comp-sci student? )

No - they didn’t really have comp-sci so to speak back then. I was in math and physics and got interested in using the computers for practical, number crunching work. We were supposed to use punch cards and take them to the IBM mainframe to be run by the priests, but I heard about the AI lab and started fooling around over there. Back then the lab was very informal, there were a lot of people who weren’t even associated with MIT in any official way there, high school kids young university students (some younger than the high school kids), it was pretty open. Anyway, I got interested in hacking on the PDP series, and that started taking up most of my time. You learned back then by reading other peoples code, asking questions and reading manuals and of course experimentation. My math professors were not very approving of my interest in computers, telling me it would ruin my mathematical career and probably also lead to warts and blindness if I kept this up. Once you wrote some programs that were useful they put you on the payroll, so I made a little money, couple of bucks an hour or so.

In the March 1987 issue of Transactor, you published an article on Blazin’ Forth. I noted that you retain the copyright to the article. Any chance that we could reprint it in C=Hacking?

Sure. That was originally just in the C64 forum on CIS, might still be there - that’s how the Transactor guys heard about it.

I found it odd that in the very same issue of Transactor, they ran an article that processing speeds of various languages for a given programming problem but did not include BForth as one of the languages. Did you ever type in the benchmark code to see how BForth stacked up to HES Forth, SuperForth, and C64 Forth? ( Not to mention the C/Pascal/BASIC compilers that were faster than any of the tested Forth implementations ).

I did. What’s more interesting to me than the fact that BForth outperformed those compilers is that a properly implement sieve in Forth outperformed that scrungy algorithm in 6502 assembler that somebody implemented. A lot of programming well is selecting algorithms and designing the program well, these language debates (higher level vs. assembler, Forth vs. C, etc. etc.) tend to obscure this fact, which is actually a much more interesting topic. At least it is to me. Which is not to say that learning different languages isn’t good, because it is. Inevitably styles and ideas are imbedded into programming languages just as they are into human languages and some things are easier to say in ‘C’ or ‘Forth’ and some things aren’t. Also, languages like Lisp or scheme can allow you the freedom to explore interesting methods of programming, such as message passing or delayed evaluation models which would be cumbersome in Forth. Once you have these concepts under your belt, you can use them in any language or dialect. But I think a lot of people are ‘coders’ and know languages, but there are very few ‘hackers’ or ‘programmers’ who are in love with clever ways to solve problems or squeeze more cycles out of a box. That’s more work, but it’s also a lot more fun and rewarding.

There are scores of enthusiasts who are either discovering the magic of the 64/128 by picking them up inexpensively, or they are using one of the emulators available for various PC/Mac/Amiga platforms. What words of wisdom pertaining to BForth would you import on these enthusiasts?

Wisdom. That sounds so boring. Have fun, experiment, don’t be afraid to crash the machine or do goofy things. Don’t assume I did everything right either, I didn’t. When you think you know enough, pick a big project that interests you and start writing it. Mostly, have fun. I don’t know if that’s the key to life, but it sure is the key to writing good software.

Thanks for the interview Scott!