The Language Guide
Eighteen chapters covering the whole core language. Every code sample was executed on both backends (tree-walking interpreter and bytecode VM); the output shown beneath each example is the real, verified output.
Coming from JavaScript, C++ or C#? The Language Bridges map what you already know onto JaiScript, one page per language, and point back into these chapters. Code moving from a C++ library (Cereal, sol2, pybind11 and others) starts in the Code Migrations.
Follow along in a terminal. Drop a sample into try.jai, run jaiscript try.jai with the standalone runner, and you get what the page shows, with one small convention: the == result: line, explained in Hello & Basics along with the two-minute setup.
One thing to know before chapter 1: the static checker is always on, and strict. A typed mistake the checker can see (a string into an int, a call with the wrong number of arguments, an undeclared name) fails the load, before a single statement runs. Chapter 2 draws the line between those and the mistakes that still wait for run time; Chapter 13 collects the whole story, escape hatches included.
Which of these rules are settled for 1.0, and which may still change in a 0.x release, is on the Stability page.
- 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 rungs of typing strictness (
intenforced,autoinferred then locked,vardynamic), the one conversion table every typed slot runs, andcast<T>, the explicit boundary. - Value Semantics & References
If you read only one chapter, read this one. JaiScript copies by default, everywhere. Here are the escape hatches (
¶meters, references,shared_ptr) and what each one costs. - 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 in declaration order, constructor overloading and delegation, inheritance with explicit
override, statics, access control, 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
The smaller conveniences: enums, namespaces, destructuring, the ternary 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 fails at load and what waits for run time, how to read a diagnostic, the promise that a clean program is never rejected,
cast<T>as the explicit boundary,extern, and 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. - 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.
- 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.