{"id":14962089,"url":"https://github.com/mitra42/webforth","last_synced_at":"2025-10-24T22:31:09.160Z","repository":{"id":57874791,"uuid":"291418449","full_name":"mitra42/webForth","owner":"mitra42","description":"Forth for the web - implemented in JS and other web technologies","archived":false,"fork":false,"pushed_at":"2024-06-19T22:28:17.000Z","size":881,"stargazers_count":31,"open_issues_count":41,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-05T14:54:40.237Z","etag":null,"topics":["arduino","forth","javascript","language"],"latest_commit_sha":null,"homepage":"https://www.mitra.biz/forth/console.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitra42.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-30T07:03:48.000Z","updated_at":"2025-06-17T22:39:54.000Z","dependencies_parsed_at":"2024-06-20T10:44:03.426Z","dependency_job_id":"2fbd25a5-ffcb-4c2d-9708-373b12c30672","html_url":"https://github.com/mitra42/webForth","commit_stats":{"total_commits":228,"total_committers":1,"mean_commits":228.0,"dds":0.0,"last_synced_commit":"bdea1c882094007009450eb55d950d646d238bde"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitra42/webForth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitra42%2FwebForth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitra42%2FwebForth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitra42%2FwebForth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitra42%2FwebForth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitra42","download_url":"https://codeload.github.com/mitra42/webForth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitra42%2FwebForth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280878370,"owners_count":26406641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","forth","javascript","language"],"created_at":"2024-09-24T13:29:07.040Z","updated_at":"2025-10-24T22:31:08.769Z","avatar_url":"https://github.com/mitra42.png","language":"C++","readme":"# Forth in Javascript\n## Why?\nI hear you ask why, which is hardly surprising. \n* Forth was the first language I got good at\n* Javascript is the language I like to play in now\n* You can run it in any browser, and on a server, and on some embedded devices\n* Its modular enough that I could replace the JS with C, C++, Wasm or Assembler.\n* Much of the Forth I've seen has been really antiquated, or over-complex, needs a fresh approach\n\n## Installation\nThe only prerequisite is [`node`](https://nodejs.org) and `npm` (or `yarn`). \n\n```\nnpm install webforth\n```\nInstalls webforth, note there are intentionally no dependencies \nin the browser versions, and the only dependency in the node version is to\nthe builtin `fs`\n\nIf you only want to host the web version, then cloning the git repo should be sufficient.\n\n## Running\n\n```\nconst {Forth, ForthNodeExtensions} = require('webforth');\n```\nOr alternatively\n```\nimport {Forth, ForthNodeExtensions} from 'webforth';\n```\nThen ...\n```\nconst foo = new Forth({extensions: ForthNodeExtensions);\nfoo.compileForthInForth()\n  .then(() =\u003e foo.interpret('1 2 3 ROT .S')) // Pass forth to interpret\n  .then(() =\u003e foo.console()) // Interactive console\n  .catch((err) =\u003e console.log('Error',err));\n```\nThis ... \n\n* loads a bootstrap JS interpreter; \n* loads forth into it; \n* switches to the forth interpreter\n* Starts a full forth console.\n\nTry `1 2 3 ROT .S` A simple forth command and output the stack\n\nThis is an experimental API - it might change, \n- see any discussion in: [issue#23](https://github.com/mitra42/webForth/issues/23).\n\nIn particular, we will be adding ability to load forth files into an instance.\n\nNote, it should be possible to run multiple instances, but this isn't tested fully yet.\ne.g. \n```\nimport {Forth, ForthNodeExtensions} from webforth;\nconst foo1 = new Forth({extensions: ForthNodeExtensions});\nconst foo2 = new Forth({extensions: ForthNodeExtensions});\nfoo2.compileForthInForth().then(() =\u003e foo2.console());\nfoo1.compileForthInForth().then(() =\u003e foo1.interpret('1 2 .S'));\n```\n## Running in a browser\n\nYou should be able to run this at https://mitra.biz/forth/console.html\n\nTo make your own copy, clone the repo,\n\nStart a simple http server such as that included in Node\n```\ncd webforth # Or wherever you cloned it\nhttp-server \u0026\n```\nOpen `http://localhost:8080/console.html` in a browser. \n\nThe HTML uses Web Components and TextEncoders, so they should work in any modern browsers such as:\nFirefox, Chrome, Opera, Edge, Android, iOS. It runs in Safari on OSX but slowly.\n\nThe phone experience of console.html is suboptimal, \nI might get around to doing a mobile friendly version eventually, \nbut if someone else does then I'll be happy to apply a PR.\n\nIt should compile Forth (you can verify in the web console) and present a console and entry box\nin which you can type any Forth. \n\nEverything is happening locally i.e. this is forth running in your browser.\n\n## Debugging\n\nFor the browser version open the Console. \nThe process of building the dictionary puts errors and progress there. \n\nFeel free to open a new issue on [the git repo](https://github.com/mitra42/webforth/issues) \nbut the first thing I'm going to ask for is a copy of whatever appeared in the Console,\nor in Node.\n\nThere are two useful Forth words you can insert in either a definition, or the code to help debug.\n* `testFlags` is a Forth variable allowing different levels of debugging. Its binary:\n  * 0x01 trace the interpreter as it loads lines \n  * 0x02 trace threading (slows it down a lot!)\n  * 0x04 enable any safety checks (currently there are not any)\n  * 0x08 run incremental tests during bootstrapping - good for catching bugs.\n* `testDepthOffset` can be set to change the number of levels deep that threading is traced\n* `Fbreak`: Just calls a short routine that generates a console log, when working in my IDE \n    I set a breakpoint here. \n  \nTODO - document how to run ANS tests from separate repo\n  \n## Arduino Support\nSee [docs/Cross Compiling.md](docs/Cross Compiling.md)\n\n## File support\nIt supports the Forth2012 file extension words `REQUIRE` `INCLUDE` etc\n\nBecause browsers don't have access to `fs` it uses a separate class\nthat imports `fs`.\n```\ncd scripts\nnode /forth_console_with_fs_via_node.js\n...\nwebFORTH V0.00.15\nREQUIRE ../sandbox/tester.f\n\\ This will load the forth in tester.f and anything that file INCLUDEs\n```\nFile support is in its early days and I want to extend it to be web-aware.\n\n## Standard support\n\nThis is intended to be standards compliant, but then Forth has multiple standards!\n\nIts status, and progress to passing the FORTH2012 test suite is visible in \n[issue#83](https://github.com/mitra42/webForth/issues/83), \nas of now (Aug 2023):\n* it implements and passes: core, coreplus, coreext \n* The following are in theory fully implemented but fail at least one test:\n  [files](https://github.com/mitra42/webForth/issues/97);\n* The following extensions are partially implemented so fail on unimplemented words:\n  [strings](https://github.com/mitra42/webForth/issues/94);\n  [double](https://github.com/mitra42/webForth/issues/93);\n* there has been no attempt to implement so the following Hayes tests fail:\n  [block](https://github.com/mitra42/webForth/issues/80);\n  Vocabularies so [searchordertest](https://github.com/mitra42/webForth/issues/95);\n* Unclear on the status of:\n  [locals](https://github.com/mitra42/webForth/issues/50);\n  [memory allocation](https://github.com/mitra42/webForth/issues/96);\n  [tools](https://github.com/mitra42/webForth/issues/95);\n  [facilitytest](https://github.com/mitra42/webForth/issues/107)\n* [exceptions](https://github.com/mitra42/webForth/issues/106)\n  - fails one test (ABORT\"), but the [standard for THROW](https://forth-standard.org/standard/exception/THROW) has problems.\n\nIn addition it does not implement (not tested by Hayes) the Forth2012 word: ENVIRONMENT?\n\n## Contributing\n\nYes please ! \n\nPlease introduce yourself on [issue#1](https://github.com/mitra42/webforth/issues/1)\n\nPull requests are welcome, and even quite significant changes at this stage, \nbut let us discuss first (open a new issue in GIT). \n\n## Cutting a release \n* Run a code inspection - surprising how many bugs this ESLint, or most IDE's catch ! \n* Update `CHANGELOG.md`\n* Check `README.md` reflects any changes\n* Update `VER` in index.js and version in package.json to next even number\n* `npm publish`\n* push to git on `master` branch\n* Update `VER` in index.js and version in package.json to next odd number\n* npm update; npm install\n* Check how to update on mitra.biz so Console runs new one ....\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitra42%2Fwebforth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitra42%2Fwebforth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitra42%2Fwebforth/lists"}