Write logic in JavaScript. Build the runtime in Rust. OakJS runs JavaScript programs the way Node.js does - the same modules, the same event loop, the same built-in modules and the same output - in one small program that starts in a few milliseconds. And a Rust application can embed it to run JavaScript plugins.
node_modules and package.json (exports, type), top-level await.console.log formatting, the order of timers, promises and nextTick, errors and exit codes.Both ways end the same: the oakjs command, ready in any new terminal. Use one of them, not both. To update later, do the same again.
The command downloads the program for your system, checks it and puts it on your PATH - just for you, no administrator needed.
Linux and macOS (Terminal):
curl -fsSL https://goldknighttech.ca/downloads/oakjs/install.sh | sh
Windows (PowerShell):
irm https://goldknighttech.ca/downloads/oakjs/install.ps1 | iex
Instead of Way 1 - no terminal needed to install: click your system below, open the downloaded file, follow the steps. It installs OakJS for everyone on the computer.
sudo apt install ./oakjs_amd64.deb.
⬇ oakjs_amd64.deb (PC)
⬇ oakjs_arm64.deb (Raspberry Pi)
| Way 1: terminal command | Way 2: installer | |
|---|---|---|
| How | Paste one line, press Enter | Download, double-click, Next → Finish |
| For | You alone - no administrator password | Everyone on the computer |
| Where | Linux, macOS: ~/.oakjs/bin · Windows: %LOCALAPPDATA%\Programs\OakJS | Linux: /usr/bin · macOS: /usr/local/bin · Windows: C:\Program Files\OakJS |
| Remove | Delete that folder (section 4) | Like any program (Settings → Apps; sudo apt remove oakjs) |
| Result | The same oakjs command, on your PATH | |
Just the program, to put where you like: Linux x86-64 · Linux arm64 · macOS · Windows · SHA256SUMS · version ….
oakjs app.js arg1 arg2 # run a program (CommonJS or ES module) oakjs # the prompt - type .exit to leave oakjs -e 'console.log(require("os").platform())' oakjs -p '[1, 2, 3].map(x => x * 2)' oakjs --help
A web server in four lines - save it as server.js, run oakjs server.js, open http://localhost:3000:
const http = require("http");
http.createServer((req, res) => {
res.end(`Hello from OakJS - you asked for ${req.url}\n`);
}).listen(3000, () => console.log("http://localhost:3000"));
Not there yet: streams (fs.createReadStream, child_process.spawn, streaming HTTP bodies), net/tls/dgram, zlib and worker threads. A program that needs them says so with an error.
Update: the same way you installed - run the command again, or download and open the new installer.
Remove - installed with Way 2: like any other program (Windows: Settings → Apps → OakJS; Linux: sudo apt remove oakjs; macOS: sudo rm /usr/local/bin/oakjs). Installed with Way 1:
# Linux and macOS (and remove the "# OakJS" lines from ~/.zshrc, ~/.bashrc, ~/.profile) rm -rf ~/.oakjs # Windows (PowerShell) Remove-Item -Recurse "$env:LOCALAPPDATA\Programs\OakJS"