Native Shell
Native Shell: AI-generated UI, native in your app, on every platform. Apps on iOS, Android, macOS, Windows and Linux, GPUI apps and web pages load signed, sandboxed TSX modules at run time and draw th
A small, mostly standard Forth in the browser.
Translation pending
Developer toolsJavaScript · HTMLGitHub @cstroieOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
A small, mostly standard Forth in the browser: compiled words, return stack, DO/LOOP, BEGIN/WHILE, CREATE DOES>, live stack view. Zero dependencies.
Taken from the repository README
Loading the full README.
Read the full README ↗A small Forth that runs in the browser, close to the standard. Colon definitions are compiled, there's a real return stack and proper control flow, and the terminal shows the data stack live. There are no dependencies and no build step.
Live demo: https://cstroie.github.io/forth/
2 3 + . \ 5
: square ( n -- n*n ) dup * ;
7 square . \ 49
: countdown ( n -- ) begin dup . 1- dup 0= until drop ;
5 countdown \ 5 4 3 2 1
Type help for an overview, words to list every word, and see name to show a definition. The Examples panel loads ready-made programs:
CREATE … DOES> arraysmsCASE and KEY<# #>| Area | Words |
|---|---|
| Stack | dup drop swap over rot -rot nip tuck pick roll ?dup 2dup 2drop 2swap 2over depth clear >r r> r@ |
| Arithmetic | + - * / mod /mod */ negate abs min max 1+ 1- 2* 2/ and or xor invert lshift rshift random |
| Comparison | = <> < > <= >= 0= 0<> 0< 0> u< within true false |
| Output | . u. .r .s ? emit cr space spaces type ." .( page / cls, decimal hex binary |
| Control | if else then, do ?do loop +loop i j leave unloop, begin until again, begin while repeat, case of endof endcase, recurse exit |
| Defining | : ; variable constant value to create allot , c, does> ' ['] execute literal char [char] |
| Memory | @ ! +! c@ c! 2@ 2! here cells cell+ chars char+ 2variable 2constant |
| Compiler | immediate postpone [ ] literal compile, marker forget |
| Formatting | <# # #s hold sign #>, s>d d. |
| Input and time | key key? accept ms |
| Floating point | f+ f- f* f/ f** fnegate fabs fsqrt fsin fcos ftan fatan fexp fln flog floor fround fmin fmax, fdup fdrop fswap fover frot fdepth, s>f f>s f= f< f0= f0< f. f.s pi f@ f! fvariable fconstant |
| Strings and comments | ." text", s" text", ( comment ), \ comment |
| Tools | words see help cold |
| Storage | save name, load name, files, delete name |
How it behaves:
true is -1. / and mod round toward negative infinity (floored division).1.5, 2e0) is a float.base. A prefix overrides it: $FF is hex, #10 decimal, %101 binary, and 'a' is a character code.ABORT does. The message points at the word that failed, for example 2 3 >>>foo<<<.key waits for a keystroke, accept reads a typed line, and ms pauses without freezing the page.Tab completes word names. ↑/↓ scroll through history. Esc or Ctrl+C interrupts a runaway word: the interpreter runs in time slices, so begin again can't freeze the page.cold starts from scratch.The page is a Progressive Web App. Your browser offers to install it (on a phone, use Add to Home Screen). After the first visit it also works offline: a service worker (sw.js) caches the app and refreshes it in the background, so updates appear on the next visit.
forth.js holds the interpreter: outer interpreter, compiler, inner interpreter and the built-in words. It doesn't touch the DOM, so it can run in Node:
const { Forth } = require('./forth.js');
const storage = { get: () => null, set: () => true, remove() {}, keys: () => [] };
const f = new Forth(text => process.stdout.write(text), storage);
f.enter(': sq dup * ; 12 sq .');
f.runSlice(); // prints "144 ok"
index.html holds the terminal user interface.
node --test
The tests run the interpreter core under Node (version 18 or later) with no dependencies. GitHub Actions runs them on every push.
This started as a fork of eatonphil/jsforth (2013–2015), a micro-Forth Phil Eaton wrote for a programming-languages course. Version 2 is a complete rewrite. The original passed words around as strings and re-interpreted them; this version compiles definitions into code, runs them on an inner interpreter, and uses standard Forth behaviour throughout.
Programs saved with the old save command can still be loaded with load.
MIT. Original © Phil Eaton, rewrite © Costin Stroie.