The Language Guide
Twenty chapters. Every sample ran on both backends (the bytecode VM and the tree-walking interpreter), and the output under it is what they printed. To follow along, put a sample in try.jai and run jaiscript try.jai (setup).
The static checker is always on: a mistake it can see (a string into an int, a wrong argument count, an undeclared name) fails the load before any statement runs. Chapter 2 draws the line between load and run time and chapter 13 has the whole of it.
Coming from JavaScript, C++ or C#? Start at the Language Bridges; code moving from a C++ library starts at the Code Migrations. What is settled for 1.0 is on the Stability page.
The language
- Hello & Basics
Run a script from C++, meet the values and literals, learn print/format, and see how the last expression becomes the result.
- The Type Ladder: typed, auto, var
Three ways to declare a variable (
intenforced,autoinferred then fixed,vardynamic), the one conversion table every typed slot applies, andcast<T>. - Value Semantics & References
Assignment, parameters and returns copy, class instances included. The ways to share (
¶meters, reference declarations, range-forauto&,shared_ptr,cast<T&>) and the lost-write check. - Operators & Arithmetic
The full C++ operator set with checked overflow, no undefined behavior, char promotion, a contractual evaluation order, and operator overloading on script classes.
- Control Flow
if/while/for, range-for, switch with break-by-default, try/catch/throw, and the execution budget a runaway script cannot catch its way past.
- Functions & Lambdas
Every C++ way of spelling a function, default arguments, lambdas with real capture lists, closures that outlive their frame, and functions as values.
- Classes
Fields, constructors and delegation, class values that are never null, inheritance with a required
override, statics, access control, destructors, and hot reload with instance migration. - Coroutines
coroutine/yieldwith handles advanced bynext(): drivable by range-for, storable in fields, alive across separate executes. - Containers & Strings
Arrays, ordered maps, typed containers, the full string method set, template strings with format specs, and byte-level string reads.
- Modules: include vs import
includeruns every time;importcaches with timestamp awareness. Hot reload falls straight out of that split. - Enums, Namespaces, Destructuring & Friends
Enums as types, namespaces and
using, destructuring, the conditional operator and null-safe access. - Reflection: reflect::
Ask, act, and navigate by name: fields, methods, get/set/invoke, spawn-by-name. Live queries that survive hot reload, enforcing exactly what direct syntax enforces.
- Types That Fail Early: strict checking
What the checker catches at load, what waits for run time and why, how to read a diagnostic, and the opt-outs:
var,cast,externand the[[warn_mode]]/[[strict_mode]]attributes. - Time: Clocks, Stopwatches & Dates
The
time::namespace: monotonic and wall clocks, value-type stopwatches, validated calendar dates in UTC or local time, templates with format specs, and a clock a host can replace. - Math: Vectors & Colors
The
vec2,vec3,vec4,ivec2,ivec3andcolorvalue types, their operators, the component-wise and geometry libraries, perceptual color mixing, and packed vector arrays. - Parallel Loops
parallel_for,parallel_transformandparallel_reduce: what a parallel body may and may not do, writes through the loop variables, constructing objects, C++ calls, and reductions that match the serial result at every worker count. - Random Numbers & Crypto
The
randomtype: a generator you own, seeded streams that replay bit for bit on every platform, copies and save files for rollback, and draws in parallel loops; thencrypto::for secrets: secure random bytes, SHA-2, HMAC and PHP-compatible bcrypt passwords.
Hosts & tools
Features of a particular host rather than of the language: web:: is an opt-in library a web host such as jai_spider registers, templates are engine built-ins present in every host, and the terminal chapter uses the standalone runner's keyboard and screen functions.
- The web:: Library
HTML escaping, RFC 3986 and form percent-encoding, query strings and URLs as pure functions over strings: the opt-in library a web host registers.
- HTML Templates
template(path, names...)renders an HTML file with escaped${...}splices, checked at load and reloaded on edit;scoped_templaterenders untrusted templates over a copy of a map. - A Terminal Game in One File
A real-time game the standalone runner plays: keyboard polling with
read_keyandkey_down, frame pacing, frames drawn with ANSI escape codes, the terminal's size, sound and saves.