Smart I Want

Find the smart technology solutions

Web Pages Via Forth

Forth. You either love it or you hate it. If you have struggled to work on tiny microcontrollers, you probably are in the first camp. After all, bringing up a minimal Forth system is pretty simple and requires very little resources on the CPU. Once you have such an environment it is then easy to extend Forth in Forth. [Remko] decided he wanted to build a Forth compiler that uses WebAssembly and runs in your browser. Why? We’ve learned not to think about that question too much.

The world has changed a lot since the first introduction of the WorldWideWeb browser in 1990. What started out as a way to show text documents over the network has become — for better or worse — an application platform. JavaScript won the browser scripting language wars and security concerns pretty much killed Java applets and Flash. But JavaScript isn’t always fast. Sure, there are ways to do just in time compiling, such as Google’s V8 engine. But that compile step takes time, too. Enter WebAssembly (or Wasm).

Just as a C programmer might write certain parts of her code in assembler for performance, a JavaScript developer can build speed-critical code in Wasm. Wasm defines a text format and a binary format that is easy for the browser to digest and execute. The Forth compiler uses mostly the text format with some JavaScript for a few functions. Of course, a lot of it is also written in Forth.

If you hate Forth, you’ve probably already quit reading by now. We’ve enjoyed using Forth on the BluePill which makes for a dirt cheap development system. We’ve also seen Forth in JavaScript before. It would be fun to benchmark the JavaScript and Wasm versions and see how Wasm fares.

Source link

Please follow and like us:

Related Posts