Top: Dspsys Index Prev: Dspsys Index Next: The Stack

What is Forth?

Ok, don't panic! Forth is a little different at first, but given time you will come to appreciate its usefulness and flexibility.

Forth is a high level programming language which operates similarly to an RPN (Reverse Polish Notation or postfix) calculator. It differs from typical programming languages like C and Fortran because it is an interactive language. If you are using Forth, you do not need to recompile your program to add some new functionality. You can easily define a new command and it will instantly be available for you to use.

Why do we use Forth?

We use Forth because it allows complete control over what we do while we are acquiring data. As often as not, a situation arises where the current software does not meet the needs of the observer. New commands, or words, can be created on the fly to satisfy this need. For example, you want to take some data using a couple of different filters. One (pseudo-code) way to do this would be:
    move to filter j, take a source image
    move to filter h, take a source image
    move to filter k, take a source image
    start over
typing each command over and over. Since you know you are going to do the same thing repeatedly, you might as well make your job easier (don't worry about what the symbols mean yet):
    : jhksrun ( -- )  \ Take images at j, h and k filter wavelengths.
        j   srun
        h   srun
        k   srun  ;
Now you need only type jhksrun to get images at three different filter wavelengths. If you had used the C language instead of Forth, you would have had to modify the source code and recompile the program, losing valuable time. Without leaving Forth you defined a word and used it with no time wasted.

Top: Dspsys Index Prev: Dspsys Index Next: The Stack