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.

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.
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.
npm install sai-language
yarn add sai-language
pnpm add sai-language

Creates a minimal SAI object with a main task that prints 'Hello world!', then runs it with the CLI.

// HelloWorld.sai
object HelloWorld main 1.0.0

Instantiate task
  debug 'Hello world!'

// Terminal:
// $ npx sai-run HelloWorld
// Hello world!