Color Forth

On Saturday July 26 1997 Chuck Moore gave a presentation to the Silicon Valley Chapter of the Forth Interest Group. Before his presentation he was given an award in appreciation of the development of the original Forth. Chuck was asked to clarify the dates involved. His response was that things started with the first Forth at Mohasco in 1968, they had a Forth at NRAO in 1970, Forth Inc. was founded in 1973, and that since it was almost 1998 and he had been born in 1938 that he had been working with Forth for almost half of his life.

I took these notes so that more people could encounter many of the ideas he presented. This is not an official transcript as I missed some of what he said. I made an effort to get a recording but there were technical problems. In the actual speech some of the thoughts were a little better connected with some material that is lost here. I have not included the questions or discussions. I will leave that for other people who were there to do.


Charles Moore:

I'm back.

OKAD was a mistake. I have added Forth to OKAD. It was done in the most expedient way but not the best. Forth is running under OKAD and I will eventually get OKAD running in Forth.

A few years ago I gave up on Forth, it was too complicated. It was about the time of the work of the standard committee and I wanted something simple. I abandoned source and used a decompiler to view the object code. It did not really work. I also wanted to get away from the keyboard.

OKAD was object code on the Pentium with a 7 key interface. I still think it is the best way to edit layout but it is bad for everything else. The problem with menus is the scripting. You can't easily edit a script that navigates menus. It was brought home to me when testing chip layout. I have lots of tests that I have to do and I couldn't easily construct them or repeat them automatically.

For years I have been saying "The map is not the territory." A description of a program is not the program, a description of a test sequence is not the test sequence, a description of a chip is not the chip. I was partially wrong. The map is a better representation.

I never claimed to be one right, or two consistent. (laughter) I hope I keep learning.

Given that I won't be working with object code manipulation I need more than 7 keys. I need a standard 83 key keyboard. I don't need all 101 keys to use source. In 30 years I still see that Forth is the best way.

First of all it has a data stack. It is the only language with a separate data stack. Second it has colon definitions.

: XYZ ;

is a beautiful and simple concept. What could be simpler? It forms the entire metaphoric background for factoring.

There is a problem that I first saw at iTV. It was the first time I have been in the presence of a Forth project that I wasn't contributing to. I saw how other programmers use Forth. They don't always get it right.

Besides stacks plus colon definitions there is something else. There needs to be another book written about writing good code.

In my case it all goes back to my father. Where I grew up we had a fall season. In the fall one of my jobs was to get the leaves out of the hedge. My hands were small and I could get my hands in where he couldn't. I had to get all the leaves. It was an impossible job because there are an infinite supply of leaves. I developed an attitude known as perfectionism. It is not popular but it does lead to success in some things like programming.

The best way I have done Forth was cmForth. I think of it as too complex. I want to talk about what Forth should be.

(Chuck showed an overhead with a screen dump from an OKAD diagnostic screen with many traces.)

This is the reason I wanted to get back to Forth. I am using Forth as a scripting language for chip tests in OKAD. The ability to display many signals at one time is new and very very productive. Here you see pads, these dots show the state of each net on the chip, and these lines are signal traces. This is a hard copy of a screen in OKAD. I added print screen to OKAD. I reversed the background color and made some other transformations. This is not the Windows PrtSc, it is mine. It was a tiny amount of work. I can now build up a book showing which tests were run and the results for a given chip providing that there is a way to describe a test. (Forth)

What do I mean by Forth? Here is code for i21. (Chuck showed another overhead with a different screen dump from OKAD) Notice the big letters and that this is a 256 byte block. A 1024 byte block would be too big to fit on this screen. I have written four i21 compilers. This one is a 1K source code assembler. I am pleased with it. This is the smallest one and it seems you can fit more on 256 byte blocks than 1024 byte blocks. (Chuck showed second screen)

At the top is a comment. The comment ends in a single quote. I use my own 0-Z character set. It is a six bit character set. It only has upper case and there is no distinction between the letter "O" and zero. This was not a problem with the menus but I do now have to deal with it in the source. The word COUNTER' is a comment. The word EMPTY is well known. 11 LOAD is the command to load screen 11. Then you see : G0 C0 ON G G G G G G G G G G PRINT ; Ten "G"s is simpler than a loop.

I don't smudge and unsmudge words so you must redefine words with a new name. If you redefine a word it would call itself recursively. This is the simplest way to do it.

It is a problem that Forth is thought of as a command line interpreter. This is an obsolete concept. I use space as a terminator and words execute immediately, there is no CR to mark the end of the line. There are no CRs, just space delimiters. I currently have BS and Delete. I would like to keep only two special keys, BS and a key to exit. I think I would prefer BS over Delete.

This uses a full screen editor. I am not sure I want a full screen editor. Maybe I will use the old Forth Inc. style find and replace style editor.

I use very few instructions on the Pentium to implement i21 instructions. This will make it portable to i21.

In general it is not too offensive to have wall of characters, even without word wrap. (referring to the look of the text in the block with no CR delimiters.) But it is not ideal.

I encourage people to write their own Forth. The standard doesn't mean that you cannot invent something. I propose here to make use of color.

In : G0 the name defined by colon appears in red so we don't need colon. The body of the definition is a different color. You can tell if it is compiling or interpreting by the color. Rather than use COMPILE you just set the color. Just set the color of a word to make it IMMEDIATE.

The color is set by a color set token that looks like a space. The comment is a different color. No delimiter other than color and space is needed. Decimal numbers may be distinguished from Hex numbers by their color. And on i21 we also use a Hex pattern representation that has been exclusive ored with AAAAA and that is a different color.

How many colors can be useful? Things like DECIMAL inside and outside a definition confuses beginners.

Target compiling is not the target. (its an interactive Forth) I can remove colon, semicolon, parenthesis, number base, and compiling words. I have not done his yet. (you can see that colon and semicolon are still there in the printout)

Some of the people who don't like Forth might take to this. In 20 blocks of code I have no conditional statements or loops. Good Forth minimizes the number of conditional statements. The minimum is zero. There are no good looping constructs in i21. I can say

: 5X X X X X X ;  : 20X 5X 5X 5X 5X ;

This is just as good as a loop. When running through memory the code should compare an address to terminate rather than use a loop count. If I need conditional code I would like to use Wil Baden's Flow Diagrams.

OKAD is written in assembler. It was converted from object code only. A chunk of OKAD is Forth. I have a symbol table in OKAD and it is used by the Forth. The compiler compiles code for the Pentium and it is subroutine threaded. + AND OR 2* 2/ are inlined other things are subroutine calls. It runs fast. It compiles fast. You don't see it compiling at all on my small programs. You load a block and the definitions are available before your finger leaves the key. They don't need to know it is a compiler, just that it has a stack and colon definitions.

It should take five to ten minutes for anyone to learn this language.

Things have changed in 30 years. For one thing there is lots of memory. You can't buy a computer with a small amount of memory. So blocks are in RAM. I have 100 256 byte block buffers. I use DOS to read these in from disk when I start. There is no need for disk access while running. Also we now have the internet. There is no reason for a computer that is not attached to the internet. When attached to the internet there is no need for a disk, you just read from the server. The computer can be this big plus a keyboard.

I saw an article the other day on web languages. I read the article and visited the web site. Forth was not one of the languages. It is clear that Java is only one among many and Forth should be there. I was enamored of tokenized Forth, we can have tokenized Forth like Java. But it would require a standards committee.

I had reservations about ANSI. I worried that it would be a disaster and not merely a dubious advantage. All of my fears of the standard and none of the advantages of the standard have come to pass. Any spirit of innovation has been thoroughly quelched. Underground Forths are still needed. I said I thought the standard should be a publication standard but they wanted an execution standard.

On the net we have no time to make a net Forth standard. So that means source code. Mine will have color change words.

There are several components to Forth. The most mysterious is why it works so well. There is the explanation by that it has to do with logarithmic rather than linear growth. And factorization promoted by the language encourages factorization of the problem in thought.

The medium of interchange is ideas not code. Tell me how you did a heap sort, don't give me your code. I have objected to Forth Dimension's pages and pages of source when one block has the key definition. It just makes it harder to find what I want to know. I won't use your code anyway I will rewrite it.

There is a problem with conversion of some of OKAD from being menu driven to a command line. I find that about one half of OKAD is displaying. Most of Windows is presenting I/O to the user. A command line eliminates that.

On the net you can easily access other people's code. You can share code though I don't do that. You can share code if you both use the same type of source. Source code is characters. What I have in mine is not ascii. I have colorful delimiters. I could use ascii but I like the 0-Z set as six bits. I wonder if the NSA would figure out that you couldn't decode my text down to eight bit characters. We get compression from not using ascii. It is a form of encryption. I know email protocols use seven rather than eight bit characters.

I want multiple entry points to defined words so I don't need a semicolon. I may not want a semicolon to stop the compiling. That is easy for me to do this way.

I don't like the idea of a Forth, old or new, that does everything.

You have to get connected on the net. I don't know if you really need a full TCP/IP protocol, just something to get out there and talk.

The advantage of customizing your browser is almost nil. You can only customize Netscape so much. I can't eliminate cookies completely but I can get a message and stop them whenever they are requested. There is much more choice on the net than I am aware of. There are lots of things to download and I don't do that. You can easily write your own software if you can use other people's software easily.

I am utterly frustrated with the software I have to deal with. Windows is beyond comprehension! UNIX is no better. DOS is no better. There is no reason for an OS. It is a non-thing. Maybe it was needed at one time.

I detest Netscape. I switched to the Internet Explorer even though I detest MicroSoft worse than I detest Netscape. I detest MASM. I discovered MASM clobbers my reserved memory. It says it will respect it but it doesn't. I've tried Word, WordPad, and Edit and they are unusable.

I would like a floppy, one meg is enough. It would have a 10K program and the rest is data. When it boots it gets into memory and is ready for operation while the rest of memory is loaded. It should start in a second or two. You don't want to do this on your hard disk and turn it into a dedicated machine.

The OS companies have not changed with the world. It is not needed but they are doing very well.

What I am proposing, free access to the internet, could be rendered illegal. I use six bit characters so it is even more dense than eight bit tokens. I would like to surf the internet in my own fashion.

There is an opposition to standard Forth. The word WORD is an anathema, it shouldn't exist. The word WORDS is just as bad. It just confuses a beginner to see a long list of words that they don't understand.

What I want is a browser, a word processor suitable for editing short email messages, and OKAD. I don't want games or a spread sheet. If I want games I will put them on a different computer.

You can do three things with a computer. You can try to make money and that is unlikely. You can try to become famous and that never happens. And you can have fun and that always works. Though at times for me it has become work rather than fun.

I am not in the business of promoting Forth. I am not promoting what I am doing here. I am just reporting it. I know that Forth is a better solution.

I have twenty more years. The whole world was keen on the pull down menus and grunt idea so I tried it. It does not work. It gets back to "the map is not the territory." I must edit test scripts in OKAD so I use Forth.

If I run out of things to do in the future I will work on voice recognition. But I think there is the problem that if their is someone else around I don't want to be muttering to my computer. I will need a keyboard.

The concept that programming is something that you need special education to do is not right. It is something that is promoted by the priesthood.

One year ago I encouraged everyone to write their own OKAD. Since you didn't do that I don't feel guilty. I assure you that I am now on the right track and I encourage you to experiment with color Forth.

UltraTechnology logo
Ultra Technology
2512 10th Street
Berkeley, CA 94710