Why F?

David Epstein
Imagine1, Inc.

When I told somebody at Supercomputing '97 in San Jose that F was ``designed for education'', she replied, ``What exactly does that mean?'' Apparently, the claim ``designed for education'' is used elsewhere, so I was being challenged for some sort of proof.

``Great. Where do I find more information about F?'' This was her response when I gave her the following background.


My First Bug

It took me over twenty four hours to find and fix my first programming bug. I had missed a single character on a punch card and had no idea what was meant by the message

  7: incorrect statement

It seems the professor forgot to inform us about deciphering error messages, so I had no idea what or where the error was. I had misspelled the word INTGER (forgot an ``E''.) After dropping my program cards and resorting several times, it took the aid of a student that had passed the class the previous semester to locate the error.

In F, if you misspell the word INTEGER, we tell you, ``You misspelled the word INTEGER.'' (There was obvious interest at this point in the conversation, so I continued on that point.)

You will note that we know when a word is misspelled, but we do not automatically fix it. That would essentially result in an extension to the language. Instead, we report it and require the student to fix it. We can, however, fix it within the compiler so no further error messages result. This is extremely important on constructs such as IF, since a beginner is likely to look at the last error message instead of the first; reporting that the ENDIF statement does not have a matching IF statement serves only to confuse the amateur.

If you miss a comma or a colon, we can tell you exactly what is missing. As well, there are no curly brackets (``{'',``}'') or semicolons in F. We emphasize words, like POINTER. If something is a pointer, you use the word POINTER. Pointers can only point at targets, which require the word TARGET.

Error Messages

There probably is really only one answer needed for your question--ERROR MESSAGES! The single most important feature required by the absolute beginner is good error messages. Having written compilers for the world's largest computer company, I know that error messages are usually saved for the end--hastily thrown in after the testing for ``getting it right''. As well, many different developers have written these error messages, so consistency is not likely.

One problem with the choice of teaching today's most popular professional programming language for INTRODUCTORY PROGRAMMING is that the software is designed for professionals. The message

syntax error

is often enough for a professional if it points to the offending line. What languages like F and Pascal can offer is an increased probability that everybody gets a chance to program--not just ``the smart kids''.

F_world

By the way, having designed F to be both simple and powerful, we were able to design a tutor called F_world (currently available on the free Windows 95/NT download) that walks a beginner through the writing and running of their first program. [Note that this version requires a password, which is in the README file.] Instead of simply printing ``hello world'', which often takes pages of explanation in introductory C, C++, and Java textbooks, the F_world program will add numbers until zero is entered.

The F_world ``beginner'' program uses a program, a module, a subroutine, and sixteen of the F statements. That's about half the number of statements in the entire F language!

I have personally watched dozens of beginners use F_world to write their first F program in about 30 minutes. The longest it has taken was around 45 minutes. About 75% get it right. The youngest F_world graduate was an eight year old. He did it faster than his parents.

Warning

Beginners have a better chance--programmers tend to start typing as soon as they get a window, or the glance over the F_world directions and miss too many steps (I have to give this warning as my customers are usually instructors or programmers and they forgot what it was like to not know how to program.)

Java

Everybody I talk to is interested in teaching Java, but don't know how to start. F was designed the same time Java was designed. The similarities between F and Java are amazing. The core design choice in each language is that procedures must be encapsulated in some more powerful mechanism. In F, every function and subroutine must be in a ``module''. In Java, every method must be in a ``class''.

The two languages diverge when it comes to inheritance, but that is often not taught in the first semester anyway. Indeed, the high school AP test uses a subset of C++ and inheritance is one of the excluded features. F modules are a wonderful tool for teaching data encapsulation, and that appears to be a focus for the first semester computer science class.

We have written an article, featured in 1997 September MacTech magazine, ``The F Programming Language Tastes Like Java.'' Hardcopies of this article are available (send me email).

A Northern California university will be teaching a combination of F and Java in their CS1 (introduction to computers) class this spring semester. We will be sure to point to the results.

Conclusion

I make sure not to let the customer walk away thinking that F is just a toy language, only good for beginners. F is extremely powerful, particularly for numerical programs. I like to use F, however, for general applications. I wrote the front end of the F compiler in 30,000 lines of F, on a 486 DX2/66 portable with 12 MBytes of memory. Minimal changes were made to get this code to run on PC Linux, Unix, and Macintosh (from back-slash ``\'' to forward-slash ``/'' to colon ``:'' and a few others for the Mac).

F is portable! F is compiled. I like to say, ``Runs efficiently everywhere''.

Imagine1 is actively looking for schools (all levels) interested in teaching F. Be sure to contact us (info@imagine1.com) for more information.