Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up
Cannot retrieve the latest commit at this time.
| Failed to load latest commit information. | |||
|
|
as | ||
|
|
bootstrap | ||
|
|
forth | ||
|
|
LICENSE | ||
|
|
Makefile | ||
|
|
README | ||
|
|
main.go | ||
README
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.