CommunityNews

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

OvermindDL1

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

Where Next?

Popular Backend topics Top

First poster: bot
It’s Time to Say Goodbye to Docker. Docker is not the only containerization tool out there and there might just be better alternatives… ...
New
New
First poster: AstonJ
Is Rust Used Safely by Software Developers?. Rust, an emerging programming language with explosive growth, provides a robust type syste...
New
First poster: bot
C++ Programming - The State of Developer Ecosystem in 2021 Infographic. The State of Developer Ecosystem 2021 is a detailed report about...
New
First poster: KnowledgeIsPower
Rocket is a web framework written in Rust. It provides a concise API and is opinionated and feature-rich beyond what you would typically ...
New
First poster: bot
50 Years of Prolog and Beyond. Both logic programming in general, and Prolog in particular, have a long and fascinating history, interm...
New
First poster: bot
GitHub - audulus/rui: Experimental Rust UI library. Experimental Rust UI library. Contribute to audulus/rui development by creating an a...
New
First poster: AstonJ
GitHub - redneckbeard/thanos: Ruby → Go at the snap of your fingers. Ruby → Go at the snap of your fingers. Contribute to redneckbeard/t...
New
First poster: bot
GitHub - clojure-rs/ClojureRS: Clojure, implemented atop Rust (unofficial). Clojure, implemented atop Rust (unofficial). Contribute to c...
New
First poster: bot
user-defined iteration using range over func values · Discussion #56413 · golang/go. There is no standard way to iterate over a sequence...
/go
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
New