Portability and Power with the F Programming Language

This article describes some of the design goals of F, a new programming language, and introduces most of the language specifics.
Module Oriented Programming

Programming in F can be called module-oriented programming. Much like Java's requirement that all procedures appear in classes, all F procedures appear in modules. An F program that does not use any modules cannot call any subroutines or reference any functions. Modules can use other modules to access their public entities. A module, however, is not allowed to use another module for the purpose of exporting the public entities in the used module unless the sole purpose is to collect a group of modules and make all their public entities available from one module.

This simple yet powerful method of module inheritance allows for an involved hierarchy of modules without complicating the investigation required to understand somebody else's code. Any reference to the function foo is known at compile time to be specifically a reference to a public function named foo in a specific module. Even without the aid of compiler tools, F is designed so a quick search (with the aid of grep) for the words “function foo” will most likely show function foo's definition line on your screen.

A nice educational feature of F is that every procedure must be declared as either public or private. The result is that a student writing a program that calls a subroutine must learn (or at least enter) the words program, use, call, module, subroutine and public. The public and private list also aids the professional as the first occurrence of a procedure name in a module will tell you if it is private and thus isolated to this module.

Overloading Procedures and Operators

F allows overloading procedure names as well as overloading operators. Every reference, however, is resolved at compile time. Thus, the statement

left = swap(int1, real2) * "hello"

displays an overloaded multiplication operator operating on the result of the int1/real2 swap and the character string “hello”. Also, swap can be a generic name, but it is also resolved to a specific function at compile time. Finally, the assignment operator (=) may also be overloaded; a mouse click on the = could conceivably direct you to the specific subroutine that would be called if this was not an intrinsic assignment statement.

More About F ... A Surprise?

Before reading this section, you may want to view the example F program found in Listing 1,1 the Sieve of Eratosthenes. to see if you can guess what once-popular programming language F is based on. The name of the base language is often deceiving as the little known 1995 standard of this language is far more modern than the popular 1977 version. As the standards team is working on making the 2000 version even more object oriented, compilers for the 1990 version have become available from most vendors only in the last few years. If you have not guessed yet, you may be surprised to find out that today's best structured programming language is based on the the world's first structured programming language—FORTRAN.

Listing 1. Sample F Program

Now over 40 years old, more programmer energy has gone into the evolving definition of FORTRAN than any other programming language. Every F program is a FORTRAN program. With stronger object-oriented features scheduled for the year 2000 and continued support for the numerically intensive programmer, this recently forgotten programming language is poised for a strong comeback during the next decade.

A strength of FORTRAN is that the standard is constantly being updated with new features. Vendors are relying on the standards efforts and announcing new compilers after the specifications have been accepted. This is a strong portability statement when compared to languages that are attempting to standardize after various compilers are already in the market. Another push for portability is being made with the addition of Part 3 of the FORTRAN standard regarding conditional compilation expected within a year.

Free For You

The Linux educational version of F is freely downloadable. The Imagine1 web page (http://www.imagine1.com/imagine1/) contains the free Linux version, and free trail versions for Windows, PowerPC Macintosh and Unix. You will also find the BNF for F, many example programs, descriptions of F textbooks, and an invitation to join the f-interest-group. As a point of reference, nonLinux users pay $101US for an F compiler and book.