/eForth.js

eForth in Javascript - one file does it all

Primary LanguageJavaScriptMIT LicenseMIT

eForth.js - Forth in Javascript

With a 100% Javascript implementation, Forth can be run from within just a single web page on your desktop or even cellphone.

Provided here is eforth.js, the only file you need! Well, if you insist, maybe an extra index.html to wrap it up or to customize to your heart's content. Simply copy both of them from the root directory shown above to your local directory. Click on index.html and you have a Forth engine ready to play. Without surprise, you should get something like the left hand side snip below.

We've come a long way from the good old green terminal days. So, with some HTML stuffs, it can certainly be more mordern! Checkout src/eforth8.html which is still work in progress. With the same eforth.js, you can create whatever presentation you fancy...

.....

Installation - Simple as 1-2-3.

  1. From root directory shown above, download or cut-n-paste eforth.js and index.html to any of your local directory,
  2. Find the index.html we've just saved in your FileExplorer (Windows), iFile (Mac OS), or Files (Linux),
  3. Click it, and your favorate browser should open automatically with a page with eForth screen shown. It's that easy. Have fun!

Fancier UI - with CodeMirror, tooltips, ...

As shown in the right-hand side picture above

  1. Clone https://github.com/chochain/eForth.js repository to your local directory,
  2. In your FileExplore, find src/eforth8.html below the root directory,
  3. Click it, and there you have it. A nicer UI, and optionally, you can open browser's Web Developer Tools on the side to monitor console output. The editor shows up once you click the 'pencil icon' in the function bar atop.
icon description
home clear text
file+ create new file in your local directory
file open a file
file<- save your updated file to your local directory
boot forget all words defined and clear text
down arrow execute selected/high-lighted section of Forth code
run execute entire file shown

Note if you kick-off the eforth8.html page from a webserver (as described below), the embeded Forth in the page also can be executed.

Javascript Modules

Should you plan to incorporate eforth.js in a larger project, or maybe you care for modulization in fashion of the ES6's new feature i.e. ease of source code maintenance

  • check the /modules directory for individual functional areas.
  • eforth_w_module.html in the root is provided as an example to import modules
  • note that, without a bundler (i.g. Webpack, Browsify, ...) to tie modules together, one will need a web server to push all the modules to your web-browser
    • a script serv.py in /tests directory is provided to kick off a Python3's simple server for the purpose. i.e.
      > python3 tests/serv.py from root directory to start you web server
      > enter http://localhost:8000/eforth_w_module.html into your browser
      

Documentation - eForth.js conforms to Dr. Ting's explaination and word list mostly.

TODO List

History - The lineage

  • It started back in 2011 when Cheahshen Yap from Taiwan FIG sent the 100-line kernel, named jeForth, to Dr. Chen-Hanson Ting, the master of eForth family.
  • Sam Suan Chen, took over the codebase (called project-k) and produced a graphic demo in SVFIG. The project took on its own path [here] now.
  • Brad Nelson, introduced a web front-end to Dr. Ting sourcing from his ESP32Forth project.
  • It sat on the shelf for years until Dr. Ting restarted his interest in Jan. 2021, completed jeforth614, and presented in SVFIG in May *(see ref. below)
  • In Aug. 2021, after working with Dr. Ting on his objectization of ooeForth (aka EForth.java) for a month, without knowing jeforth614's existance, I took interest in the 10 year old jeforth_301 and wiped it up to jeforth400. Presented to Dr. Ting on 2021/8/8 (Taiwanese Father's Day) just for a kick and a potential project path forward.
  • Dr. Ting did not like the flashy front-end at all. He striped the sidebar, dropped dependency to CodeMirror, and renamed it jeforth615.js. He, however, did include it in the published document ceforth_403.doc* and was kind enough to put me along side with him as the authors. *(see ref. below)
  • After he merged html and js into one file [jeforth616.html], Dr. Ting and I switched focus onto upgrading ceForth (C-based Forth) for Windows and ESP32 [here], and finally targeting an FPGA with Don and Demitri of [AI & Robotics project]. He worked tirelessly even from his sickbed and did not ever stop. Not until he finally succumb to the illness 2022/5/30.
  • After a few months of head-down cranking on [tensorForth], I felt that it's time to take a look at all the projects I've worked with Dr. Ting before my memory starting to fade. In Thanksgiving Day, after reviewing jeforth615, I've decided to call it eForth.js in memory of Dr. Ting.

Though I've never had the chance to meet him in person, the years of dedication and contribution he has to the Forth community is something I'll carry with me. As I told him once in the e-mail: "The name eForth will forever be associated with you, Dr. Ting".

Dr. Ting's Original jeForth live demo

Prior Art (on GitHub)

Many others have the same idea as well, each with a little different implemenation. Proof of the saying in the Forth community, instead of seen one seen them all, here you see many of the ones!

Other Refs From Lars Brinkhoff's 2017 list