What is Oforth ?

Oforth is an imperative, dynamic typed, stack-based language.

Oforth is a Forth dialect (Oforth is for Object + Forth). It keeps Forth mecanisms while implementing a full object model.

Oforth has been designed to provide :

  • A dynamic, fast, concise language.
  • An object oriented programming support and object metamodel (classes, methods, ...)
  • Automatic garbage collection with an incremental mark and sweep garbage collector.
  • Althought imperative, support of functional programming features (and closures using blocks).
  • Support for parallelism using light-weight tasks and communication between tasks using channels.

Getting started

Binary installation :

  • Download oforth release corresponding to your platform here
  • Oforth release is an archive with an oforth directory. Copy this directory at a location of your choice.
  • Set OFORTH_PATH environnement variable value to this directory (see INSTALL.TXT file for details).
  • Launch oforth interpreter using oforth --i command line : you are ready to begin tutorials here or read manual.

Build Oforth :
  • Oforth is open source : you can download the sources and build a binary (see Oforth manual).
  • Then you can change the binary provided by one of the releases.

13/10/2018 : EuroForth 2018 conference videos and papers

This year, EuroForth conference was in Edinburg.

Videos are available Here
One of them is about method dispatch in Oforth

Papers are available here

23/09/2018 : Oforth V1.2 is released

Oforth V1.2 introduces dual words (see chapters 10 and 11 of the manual)

Some changes and fixes (see change log for more information)

- Franck -

07/05/2018 : Oforth V1.1 is released

Oforth V1.1 supports Mac OS systems

Some changes and fixes (see change log for more information)

- Franck -

Some examples (from tutorials).

You can find lots of examples here

Factorial (imperative)

: fact ( n -- n1 )
   | i | 1 n loop: i [ i * ] ;

or (recursive)

: fact ( n -- n1 )
   n if n dup 1- fact * else 1 then ;

Fibonacci sequence

: fib ( n -- n1 )
   0 1 n #[ tuck + ] times drop ;

A ping pong between 2 tasks running concurrently and using channels to communicate

: pong ( n ch1 ch2 -- )
| i |
   n loop: i [ ch1 receive ch2 send drop ] ;

: pingpong ( n -- )
| ch1 ch2 i |
   Channel new ->ch1
   Channel new ->ch2
   #[ n ch1 ch2 pong ] &
   n loop: i [ i ch1 send drop ch2 receive . ] ;

An emitter that launches event listeners into parallel tasks running concurrently

import: emitter

: myemitter
| e |
   null Emitter new ->e
   $foo #[ "foo" . ] e onEventParallel
   $foo e emit
   $foo #[ "bar" . ] e onEventParallel
   $foo e emit
   e close