All Projects → unixdj → forego

unixdj / forego

Licence: other
Forth virtual machine in Go

Programming Languages

go
31211 projects - #10 most used programming language
forth
179 projects
forego - A Forth implementation in Go
=====================================

Why?
----

For ego.  This is me learning the language.  Both of them.

Someone once said that everybody who learns Forth and likes it
thinks "oh nice, that'd be cool to write a Forth VM".  This
happened to me, but I had no actual reason to do it until I
started searching for a Go learning project.


And?
----

Lessons learned: writing a VM without performance constrains or
a crude assembler is easy, wrapping your head around multiple
run times of Forth compiling words is less so.


So What Is It?
--------------

Forego is a naive implementation of a Forth virtual machine in Go
that I hacked up in a month or so.  Here are its main features
and misfeatures:

The Good:

- The compiler, assembler, parser, main loop and disassembler are
  now written in Forth.  It has (my understanding of) the full
  CORE wordset and then some, like:
    .( .r u.r :noname compile, parse parse-name refill source-id
    to value within \
    pick roll ?do again case endcase of endof
    .s ? dump words ;code ahead bye state
    /string cmove cmove> sliteral
  ...and those are written in Forth.  Type "words" at the prompt
  to see the whole list.

The Ambiguous:

- It has no file support and no interaction with the outside
  world except key and emit, so untrusted code will have to
  overflow a buffer in xterm or something to exploit your box.

The Bad:

- The VM does not resemble real hardware at all.

- The "kernel" ("machine" code) is hardcoded in the package.

- It's probably damn slow.

- The README is incomplete.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].