Playground execution — Developer Preview 0.11.0

Run executes your checked ThreadOne program, captures print output and reports real errors. Check code remains a separate operation: it checks types and emits Rust without running it. Both use the same SDK compiler frontend distributed with this release.

Execution boundary

A Rust AST interpreter compiled to WebAssembly runs in a dedicated Web Worker. It supports pure scalar expressions, functions, conditionals, immutable scalar and record lists, immutable records, Optional values, early return and fallible recovery. It does not evaluate user source as JavaScript. HTTP routes, network/database access, timers, filesystem imports, environment/argument access and JSON execution are unsupported in this browser preview. Unsupported operations return an explicit error; they are never presented as successful I/O. Use the native SDK for those applications.

Lists support Int[], Bool[], String[], declared record types such as User[], literals, len and Optional-returning list_get, with at most 1,024 elements per list. Record elements have a conservative native inline-layout limit of 256 bytes, enforced by the shared type checker. Directly nested list types, Optional elements and mutation are unsupported. Records containing list fields are allowed only when their type graph is acyclic. JSON array encoding/decoding is available only in the native SDK.

The browser interpreter is not the native Rust/LLVM executable and does not reproduce the native Tokio I/O scheduler, request arenas or native performance. Browser timings are not native benchmarks.

Limits and cancellation

Source and captured output are each limited to 64 KiB. Execution is limited to 100,000 steps (including values visited during structural equality and 64-byte string-comparison chunks), 64 nested function calls and 1 MiB cumulative string/record/list allocation accounting. The page terminates the worker after eight seconds, including loading and compilation. Stop terminates it immediately. Every new Run or Check starts a new worker, so errors, cancellation and timeout cannot leave interpreter state behind. Changing source or selecting another example also terminates the old worker; stale responses are ignored.

Output is returned on completion. A runtime error can include partial printed output. Stop or the outer timeout discards output still held by the terminated worker. Programs that print nothing report successful completion explicitly. Runtime/compiler diagnostics retain their SDK English wording; controls, status and scope explanations support English and Thai.

Build an API with the native SDK

The redis-api project template includes HTTP routes, Redis expiry, shared validation tests and a real HTTP smoke script. These operations run in the native SDK rather than the browser interpreter. Follow Start building for the complete local walkthrough.

Request query/header lookup is also native-only. Check accepts req.query(name) and req.header(name) and checks their String?! results; Run reports unsupported HTTP execution. Download the SDK to run examples/request-access.one, which handles lookup errors separately from missing values.

Why one application thread?

One owner of state simplifies reasoning about changes between suspension points and avoids shared-memory synchronization within that thread. Explicit ordering can make state machines easier to review. Waiting operations can still interleave, so single-thread execution alone does not provide database transactions, strict request ordering or freedom from logical races.

CPU-heavy work can delay all tasks on that application thread. Multithreaded computation can use several cores directly, with coordination costs when sharing state. Both models can handle concurrent I/O. ThreadOne currently uses Tokio current_thread plus LocalSet in the native runtime; a thread-per-core scheduler and structured worker API remain future work. Neither model is universally faster.