
CommunityNews
Tails, A Fast C++ Forth Core
Tails is a minimal, fast Forth-like interpreter core. It uses no assembly code, only C++, but an elegant tail-recursion technique inspired by Wasm3 makes it nearly as efficient as hand-written assembly. I created it as a one-day hack to celebrate May Forth 2021 … then kept going because it’s fun.
It started out as tiny but functional. The magic core code (
NEXT
,INTERP
,RETURN
,LITERAL
,DUP
, etc.) is about 200SLOC and compiles to a few hundred bytes, many of which are NOPs the compiler adds for padding. The parser and compiler add a few KB more.It’s grown significantly since then: there’s a parser; a stack-checking & type-checking compiler; multiple value types including strings and arrays; “quotations” (i.e. lambdas or blocks); garbage collection … but the simple core can still be extracted and used if something more minimal is needed.
Tails doesn’t follow the usual Forth implementation strategy of starting with a minimal assembly-language core and then building as much as possible in Forth itself. That makes sense for a system where you’re going to be writing applications entirely in Forth; but for my purposes I’m more interested in having an embedded language to use for small tasks inside an application written in a more traditional compiled language like C++.
Read in full here:
This thread was posted by one of our members via one of our news source trackers.
Most Liked

OvermindDL1
Heh, FORTH’s are always fun, I’ve implemented at last a dozen as a learning task in a variety of languages. ^.^
Popular General Dev topics









Other popular topics










Latest in General Dev
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /html
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /react-native
- /sublime-text
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /julia
- /slackware
- /c
- /neovim