SAI
raw JSON → 0.2.8 verified Fri May 01 auth: no javascript
SAI is a whitespace-sensitive, object-oriented programming language that transpiles in-place to JavaScript for the Node.js environment. Current version 0.2.8 (released sporadically, last update 2021). It emphasizes code readability, maintainability, and asynchronous constructs (Promises, finite state machines). Unlike CoffeeScript, SAI is an independent language with rigid parsing, collection manipulators, and compile-time sanity checks. It can be used in dynamic mode (runtime compilation via `sai-language` package) or build-time mode (`sai-build` + `sai-library` runtime). Suitable for Node.js only; not yet browser-ready.
Common errors
error Cannot find module 'sai-language' ↓
cause sai-language not installed globally or locally.
fix
npm install sai-language --save-dev (or global install with -g).
error SyntaxError: Expected 'object', got something else ↓
cause Misformed SAI source header; missing version or invalid syntax after 'object'.
fix
Ensure first line matches: object ObjectName main MAJOR.MINOR.PATCH (e.g., object HelloWorld main 1.0.0).
error ReferenceError: sai is not defined ↓
cause Attempting to use `require('sai-language')` but not assigned to a variable.
fix
const sai = require('sai-language');
error Error: Unknown option '--output' ↓
cause Using sai-build with an unsupported flag.
fix
sai-build does not take --output; it transpiles in-place. Use --help for available options.
Warnings
breaking SAI is whitespace-sensitive: indenting must be consistent (spaces only, no tabs). Mixing tabs and spaces causes parse errors. ↓
fix Use only spaces (2 or 4) and ensure consistent indentation per file.
gotcha SAI transpiled JS is not human-readable; do not modify the generated .js files, as they are overwritten on next build. ↓
fix Edit only .sai source files; run sai-build to regenerate .js files.
deprecated Dynamic mode (compiling .sai at runtime via `require('sai-language')`) may have performance penalty. Prefer build-time compilation. ↓
fix Use sai-build to pre-compile, then require the generated .js files directly.
gotcha Comments in SAI use `//` only; `/* */` block comments are not supported in all versions. ↓
fix Use line comments `//` exclusively.
Install
npm install sai-language yarn add sai-language pnpm add sai-language Imports
- default wrong
import sai from 'sai-language';correctconst sai = require('sai-language'); - SAI namespace wrong
const { SAI, compile, run } = require('sai-language');correctconst sai = require('sai-language'); - sai-build CLI wrong
require('sai-build');correctconst { exec } = require('child_process'); exec('npx sai-build', ...); - sai-run CLI wrong
import { run } from 'sai-language';correctconst { exec } = require('child_process'); exec('npx sai-run HelloWorld', ...);
Quickstart
// HelloWorld.sai
object HelloWorld main 1.0.0
Instantiate task
debug 'Hello world!'
// Terminal:
// $ npx sai-run HelloWorld
// Hello world!