Skip to content

Heracraft/nuru-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A web interpreter for Nuru -- A Swahili Programming Language built from the ground up -- powered by WebAssembly.

Getting started

Prerequisites

  • Go (^1.19.0)
  • Node.js (^18.13)

Working with the Wasm Interpreter

To build the wasm binary from the go interpreter:

  1. Change directories to /wasm
cd wasm
  1. Install the required go dependencies
   go mod tidy
  1. Create a go vendor folder
go vendor

and copy the modified builtins.go into the evaluator package

cp ./modified/builtins.go ./vendor/github.com/NuruProgramming/Nuru/evaluator/

or if you are on Windows

copy ./modified/builtins.go ./vendor/github.com/NuruProgramming/Nuru/evaluator/
  1. To build the wasm binary
wasm && GOOS=js GOARCH=wasm go build -mod=vendor -o main.wasm

or if you are on Windows:

$env:GOOS="js"; $env:GOARCH="wasm"; go build -mod=vendor -o main.wasm

notice the -mod=vendor flag in the wasm build. This is to build the project using the vendored dependencies (which now includes the modified builtins).

Web app

Powered by Svelte. To work with it:

  1. Change directories to /app
   cd app
  1. Install dependencies
npm i
  1. To start a development server:
npm run dev

# or start the server and open the app in a new browser tab

npm run dev -- --open

Workspace scripts

/package.json redefines the above commands as scripts you can run from the root folder.

npm run dev #runs the dev server
npm run build:wasm #Builds the wasm binary and copies it over to the web app
npm run replace #Replaces the default Nuru builtins with browser friendly versions

If you are on windows, edit the build:wasm & replace scripts to replace cp with copy or Copy-Item

Coming soon

  • Support for user inputs (jaza())
  • Syntax highlighting for Nuru code