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

  1. Hello & Basics

    Run a script from C++, meet the values and literals, learn print/format, and see how the last expression becomes the result.

  2. The Type Ladder: typed, auto, var

    Three ways to declare a variable (int enforced, auto inferred then fixed, var dynamic), the one conversion table every typed slot applies, and cast<T>.

  3. Value Semantics & References

    Assignment, parameters and returns copy, class instances included. The ways to share (& parameters, reference declarations, range-for auto&, shared_ptr, cast<T&>) and the lost-write check.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. Coroutines

    coroutine/yield with handles advanced by next(): drivable by range-for, storable in fields, alive across separate executes.

  9. Containers & Strings

    Arrays, ordered maps, typed containers, the full string method set, template strings with format specs, and byte-level string reads.

  10. Modules: include vs import

    include runs every time; import caches with timestamp awareness. Hot reload falls straight out of that split.

  11. Enums, Namespaces, Destructuring & Friends

    Enums as types, namespaces and using, destructuring, the conditional operator and null-safe access.

  12. 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.

  13. 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, extern and the [[warn_mode]] / [[strict_mode]] attributes.

  14. 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.

  15. Math: Vectors & Colors

    The vec2, vec3, vec4, ivec2, ivec3 and color value types, their operators, the component-wise and geometry libraries, perceptual color mixing, and packed vector arrays.

  16. Parallel Loops

    parallel_for, parallel_transform and parallel_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.

  17. Random Numbers & Crypto

    The random type: 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; then crypto:: 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.

  1. 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.

  2. HTML Templates

    template(path, names...) renders an HTML file with escaped ${...} splices, checked at load and reloaded on edit; scoped_template renders untrusted templates over a copy of a map.

  3. A Terminal Game in One File

    A real-time game the standalone runner plays: keyboard polling with read_key and key_down, frame pacing, frames drawn with ANSI escape codes, the terminal's size, sound and saves.