GRAY

Developer reference

Build with Gray's language, integrated server runtime, execution policies, runnable tutorials, and compiler-generated API declarations.

server.gy source process · replace on validation
set $server = http_server();

http_handler($server, "GET", "/hello", fn($request) {
    return response_json([
        "runtime": "Gray",
        "policy": "Live"
    ]);
});

http_serve($server, "0.0.0.0", 8080);
response 200 application/json
{
  "runtime": "Gray",
  "policy": "Live"
}
Start
Source
Change
Validated replacement
Ship
Project tree

Quickstart

Create a project and start the development server.

01gray new hello-gray
02cd hello-gray && gray run
03gray dev
<?gray
set String $name = "Ada";
?>
Hello, {$name}!

Gray files can combine source and literal output. Expressions inside {...} are rendered in place.

Language and runtime

Core syntax and built-in server capabilities.

Output

<?gray ... ?>, includes, and {expr}

Compose ordinary files in shared scope and render expressions inside literal text.

Types

Checked at the boundaries that matter

Mix typeless values with checked parameters, returns, fields, and storage.

Structure

Classes, schemas, and identity

Model state with constructors, methods, visibility, typed records, and JSON encoding.

Database

Native SQLite and PostgreSQL execution

Use parameterized SQL, typed rows, transactions, and readiness-driven continuation paths.

Security

Session Fabric is a runtime primitive

Opaque encrypted sessions, typed state, CSRF, recent authentication, bounded risk, and redacted events.

Concurrency

Structured tasks and bounded native state

spawn, await, cancellation, caches, and source-aware errors share one execution model.

Tooling

One syntax model

gray fmt, gray lint, and the LSP consume the compiler's grammar.

Execution

Policy is explicit

Run source, ship a standalone artifact, or replace ready workers after validation.

Tutorials

Runnable examples checked by the repository test suite.

Loading tutorial

Session Fabric

Session lifecycle, storage adapters, key rotation, and privacy controls.

API reference

Declarations generated from the compiler's syntax model.

Loading gray.docs.v1