Skip to content

linkedin/forthic

Repository files navigation

Forthic

Forthic is a stack-based language for making apps tweakable.

By embedding a Forthic interpreter in your application, you can make apps tweakable at runtime, even by end users. LinkedIn has used this approach to build hundreds of internal Jira-based program management tools.

This repository contains two primary Forthic interpreters: a Python-based based one that can run within a Flask app in order to create APIs that can be revised at runtime and a React-based one that can create user interfaces on-the-fly.

Documentation

For a brief overview of Forthic, see OVERVIEW.md. The SYNTAX.md file shows what the language looks like, including a brief overview of some of the standard global Forthic words. The IDIOMS.md file gives pointers on how to use Forthic the way it was designed to be used. The ARCHITECTURE.md file shows how Forthic interpreters can work within apps.

Forthic modules are documented in the modules

YouTube

There are several YouTube videos for learning Forthic

Articles

Getting started

To get started, you can run an example Flask server with an embedded Forthic interpreter that also serves React apps with embedded Forthic interpreters.

Starting the example server

# On Mac and Linux
make

# On Windows
.\make-install.ps1
.\make-server.ps1

This creates a Python virtual environment, installs Forthic into it, and runs a web server on http://localhost:8000

See EXAMPLES.md for more information.

Deleting secrets

Some examples require credentials in order to work (e.g., Jira username and password/api-token). The example server stores these on your computer as an encrypted in a JSON object in the server/.secrets file. To delete a particular secret, just remove it from this file and save. To delete all secrets along with the encryption key, delete server/.secrets and server/.key or

# On Mac and Linux
make delete-secrets

# On Windows
make-delete-secrets.ps1

Tests

Each Forthic interpreter variant has its own test suite. To run the primary tests for forthic-py and forthic-react just run

make test

Experimental Interpreters

In addition to the primary interpreters for Python and React, there are a number of experimental interpreters that show how Forthic can be implemented in other languages. Those who like learning different programming languages might find it interesting to compare the different implementations. These proto-implementations can also serve as starting points for complete Forthic interpreters.

Host Language Comments
C++ Proof of concept using C++ in .NET
Haskell An experiment to see if a Forthic interpreter could be built in a pure functional language
Julia Proof of concept in Julia
nvcc Proof of concept for building a interpreter that could run on GPUs via CUDA
swift An attempt to build macOS apps that could be tweaked at runtime
Rust A Forthic tokenizer in Rust
zig WIP Forthic implmentation using zig

Pre-forthic Implementations

Prior to Forthic, there were several experiments at building FORTH-like interpreters in a variety of languages

Host Language Comments
asm Proof of concept in assembly language
C# Proof of concept in C#
Erlang Proof of concept in Erlang, which was one of the easiest Forth-like implementations
Fortran Proof of concept in Fortran, which was the hardest Forth-like implementation