Freelang

Freelang is a stack-oriented, concatenative, compiled language for Freeputer.

Freeputer is a free computer. Free as in freedom.

Freeputer is a tiny virtual machine easily ported to most modern architectures, including bare metal, and requiring neither file system nor operating system. This offers extreme portability and the freedom to use software forever without designed obsolescence.

  • Freeputer is a virtual machine: the Freeputer Virtual Machine (FVM).
  • Freeputer is a self-hosted, self-contained software development platform.
  • Freeputer is a platform for modular software that lasts forever.
  • Freeputer is a powerful platform for bare metal computing.
  • Freeputer is a user's computer not a vendor's computer.
  • Freeputer supports the freedom of the user.
  • Freeputer is a not an operating system.

Freelang is a fairly low-level language, whose core vocabulary is essentially that of the FVM instruction set, but it is surprisingly productive and capable. It is inherently extensible. Its syntax uses reverse Polish notation (RPN).

Here is an example of a simple Freelang program that greets the user in Chinese and English:


HelloWorld{ \ This is the start of the HelloWorld namespace

  newline                 \ Write one blank line
  ." 你好 " print          \ Say hello in Chinese (comment out if unsupported)
  ." Hello world! " print \ Say hello in English
  newline
  halt                    \ Exit with success

  \ Write the supplied Freeputer string one byte at a time
  \ but do not write (that is, skip) any byte having a value of 0.
  \ This means whatever character encoding happened to have been used
  \ during the storage of that string is crudely preserved to some extent.
  \ In this case, this source code was saved using UTF-8 character encoding
  \ and so this simple technique of skipping 0-value bytes works nicely.
  \ Note: a Freeputer string starts with a word indicating its
  \ size in characters and each character is 32 bits wide.
  : print ( s -- )
    [@] 4 * swap incw swap    \ ( a z ) a=addr of 1st char   z=number of bytes
    writing:                  \ ( a z )
      go[<=0] :end            \ ( a z )
        dec swap [@b]         \ ( z- a b )
          go[==0] :skip       \ ( z- a b )
            writorb ::wfail   \ ( z- a )
            go :next          \ ( z- a )
        skip:                 \ ( z- a b )
          drop                \ ( z- a )
        next:                 \ ( z- a )
          inc swap            \ ( a+ z- )
          go :writing         \ ( a+ z- )
    end:                      \ ( a z )
      drop2                   \ ( )
      newline                 \ ( )
  ;

  \ Write a newline character
  : newline ( -- ) 10 writorb ::wfail ;

  \ Exit point upon I/O error
  wfail: halt

}HelloWorld \ end of namespace

The self-hosted Freelang compiler, flc, is written in Freelang, runs on the FVM and can compile itself.

For further information please see:

This revision created on Thu, 27 Aug 2015 07:49:02 by Freeputer (Fixed reversed order of links)