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. ^.^

Popular Backend topics Top

New
First poster: bot
Powerful, flexible, complex: The origins of C++ date back 40 years, yet it remains one of the most widely used programming languages toda...
New
First poster: bot
As I continue to work on Cyberscore, I keep finding new quirks / features in PHP and MySQL. All of the tests below are being run on mysql...
New
First poster: bot
In recent months I use Go for the implementation of Proof of Concept in my leisure time, partly to study of Go programming language itsel...
/go
New
New
First poster: bot
GitHub - vydd/sketch: A Common Lisp framework for the creation of electronic art, visual design, game prototyping, game making, computer ...
New
CommunityNews
Martin Thompson On How To Manage Software Complexity | The Engineering Room Ep. 4. In this episode, Dave Farley chats with Martin Thomps...
New
First poster: bot
GitHub - vitalik/django-ninja: :dash: Fast, Async-ready, Openapi, type hints based framework for building APIs. :dash: Fast, Async-rea...
New
First poster: bot
To build a web application you need to make architecture decisions across a range of topics. The beauty of Ruby on Rails or Django is tha...
New
First poster: bot
GitHub - Shirakumo/trial: A fully-fledged Common Lisp game engine. A fully-fledged Common Lisp game engine. Contribute to Shirakumo/tria...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
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
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New