FORTH Programming Language (Going FORTH)

posted in: Devlog, Nostalgia | 13

Why was the FORTH Programming Language used to create ChipWits?

Long, long ago in an ancient era (1984) when microcomputers were a new thing, Mike Johnston and I fell in love with the Macintosh and bought one (for $4,700!) on which to create ChipWits.

We immediately ran into a big problem—we didn’t have enough money to code the game. Developers couldn’t program directly on the Mac because there were no programming languages ready to use. Apple insisted that developers buy an expensive Apple Lisa computer to write Mac software on. A Lisa cost $9,995! That’s over $27,000 in 2023 dollars. No way!

Luckily a solution appeared. A company called Creative Solutions, Inc, came out with a Mac coding language called MacFORTH. It was based on a weird little programming language called FORTH.

MacForth Plus on 3 disks
MacForth Plus (image courtesy of macintoshrepository.org)

Luckily I had been programming in FORTH since ’82. FORTH was not a popular language, but it was often the first programming language that appeared on a new microcomputer. In the 80’s there were a bunch of micros: Apple II, Commodore 64, Atari ST, Radio Shack TRS-80, IBM PC Jr., to name a few. FORTH was one of the first languages to appear on each. Because FORTH is a simple and very small language, it was the easiest language to implement for new computers.

FORTH was a blessing and a curse. A blessing because we could write ChipWits on the Mac. A curse because FORTH is a very strange, terse, hard-to-read language.

Here is the FORTH code to add 7 to 1 and print the result:

7
1
+
.

That’s it!

Here’s what it does:

  • 7 [Put 7 on the stack (you’ll learn about stacks while playing ChipWits.)]
  • 1 [Put 1 on the stack.]
  • + [Add the top two numbers on the stack, remove both from the stack, and put the answer (8!) on the top of the stack]
  • . [Print the top number on the stack]

Easy, right?

FORTH has been called a Write-Only-Language because it’s hard to understand what you wrote when you return to the code after even a few days.

I’m glad we developed IBOL rather than making ChipWits players learn FORTH.

I dug into MacFORTH and the complex, mysterious workings of the new Macintosh, and wrote the game.

Mike Johnston and Doug Sharp Luring ChipWit Into a Trap. ChipWits was developed using the FORTH programming language.
Mike Johnston and Doug Sharp luring a wild ChipWit into a trap

We got ChipWits out the door in time for the ’84 Christmas sales. Then it was time to port the game to the Commodore 64 and the Apple II. The Mac had 128k of memory and the C64 had 64k. Most people who owned Apple IIs had only 64k of RAM. I had to shrink the program by half.

I had to do extreme things like shortening the variable and function names because they took up RAM.

The strategy of using FORTH paid off. We coded the C64 and Apple II versions in a few months.
I wish I could have programmed the game using IBOL instead of FORTH. 🙂

Discussion

Are there any other FORTH programmers out there? Share your stories about FORTH or MacFORTH in the comments below!

Thanks for playing ChipWits! Spread the word!

13 Responses

  1. Alex McChesney

    Were the ports in FORTH also or were they completely rewritten?

    • mattack

      Seems to me like the paragraph right before Discussion effectively says those were in FORTH too, and that was the reason for the quick ports.

  2. cookiejar

    IBOL is/was a brilliant move and made the logic so visual. I often wondered what ChipWits might have looked like if programmed in mTropolis, a much loved multimedia app that Quark quashed.

  3. Dave Colburn

    My brother Don was the father of MacFORTH, and I had the privilege of working with him at Creative Solutions lo these many years ago…

    Like Doug said above, the barrier to entry to writing code for the Mac early on was pretty onerous both in terms of required hardware and plowing through the API “phonebooks”. We created MacFORTH to enable what we liked to call “Programming for the Rest of Us”, and we took great joy watching MacFORTH developers creating some amazing products. Chipwits was a favorite — a pioneer in it’s time teaching the art of programming visually. Don and I spent many a late evening chasing pie and coffee and each offering “constructive criticism” to the other regarding their respective IBOL code.

    I was thrilled when I heard that ChipWits was making a return tour, and I look forward chasing pie and coffee in memory of my dear brother Don.

  4. cookiejar

    Obviously ChipWits is a game/sim first, but the logical thinking it instills reaches beyond the little bot. It might be helpful to have a place on this site linking for “next steps” in learning coding.

    One suggestion I have is Ian Davies’ S2JS (https://s2js.com). It is a hands-on lab for gravitating from Scratch to JavaScript, but not a large leap from concepts key to CW. In fact, if teaching elementary programming, I would suggest ChipWits > Snap! (https://snap.berkeley.edu) > S2JS > JS.

  5. Shimshon

    In 1990, I got a job at the Center for Astrophysics and Space Sciences in the Physics Department at UCSD as a student programmer. I was an undergraduate working with tenured professors, postdocs, and PhD candidates. I worked on the Electron Drift Instrument, which was many years later launched aboard the Shuttle. I was roughly the 30th candidate interviewed. I got the job on the spot, because I was not only the only one to have even heard of Forth out of the 30, I had actually taken a course on Forth programming. I had been interested in Forth for many years by this point. To this day, it is the coolest job I have had.

    I used LMI/32 Forth to maintain the entire test harness, which included a stepper motor to position the device, an electron gun, a channel plate (the same tech in night vision devices) to record data, sophisticated data analysis, and a GUI to run it all. I did a lot of bare metal coding to get it to work. I inherited 25 screens written by my boss, that did some very rudimentary and primitive stuff, and that ballooned to 250 by the time I left a year later, written by me. I still have the code today.

    The hardware was a 386 with a 387 (which we used extensively) and a then-enormous 8MB RAM (1MB was the base level at this time, and 4MB was a serious amount).

  6. Will Johnston

    That is such a great picture of you and Dad!

  7. Doug Sharp

    I remember talking to Don a lot! I should have mentioned how cool it was to work with Creative Solutions. Always responsive, even to my FORTH noob questions.
    So glad to hear that you guys are ChipWits fans. I know you’ll like its current incarnation.
    Stay in touch!

  8. DBPender

    I was in the audience at 3M as a member of the 3M Personal Compurter Club when Doug made a presentation that featured Chipwits. That presentation led to a contest to achieve the highest score in Octopus Gardens. The contest was very addictive resulted in several distinctive approaches to the problem. (I still have my copy of the game.)

    Oddly, I may be turning to FORTH as a solution to a problem that I have encountered at my new workplace.

    • Doug Sharp

      I remember that well! Our first meeting with a bunch of CW fans.
      One of you found a simple “solution” to one of the missions (I forget which one)–standing on a DOOR and spin around zapping. The baddies would respawn in each room and you could rack up a score much higher that hunting the baddies down.
      Please sign up for our mailing list to be a playtester in our 2nd round of testing.
      You must have googled “ChipWits” to find us.

  9. Ed Tomlinson

    I remember MacForth fondly. Coded a bunch of stuff for compressed blocks, sent all off to Creative Solutions. They liked the code but rejected it since they were moving away from block based forth… They did keep my name on file though. A couple month later I got a call from a local developer. He had built a chip editor in MacForth and wanted a few (Forth) words optimized. I did what he asked and with a few extras. He really liked the extras. One really helped with drawing speed, the other was a set of hook that enabled a powerful undo capability that persisted over saves. I did not do much more for Him. Last communications were that he was switching to 32bits (vs 16bit default in MacForth). This would allow the complete 68030 (or 68040 not sure) chip to be imported and edited using the program. The program did not use floating point – everything was done with fractions.
    If I remember correctly it did encounter ChipWits. It so captivated me that my wife asked that I erase all copies of the game :-/

  10. Doug Sharp -- Co-creator of ChipWits

    Wow! You sure got under the hood of MacFORTH. I was a user who sometimes worked with them to work out a bug in it, but never got down and dirty with the language.
    Wish I had had your fast drawing routines.
    Love that last sentence!