Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The vilan documentation

How to use the vilan language, its standard library, and the frameworks built on top of it. If you’re wondering where something lives: this book is about using vilan. Design history and rationale live in vilan/proposal/.

Parts

  • Tour — the language itself, taught informally. Start with Coming from JavaScript if that’s your background, then read in order. Come back any time you need a syntax reminder.
  • Guides — the frameworks, task by task: reactive state, building UI, styling, routing, talking to a server. Each guide reads front to back and links into the reference for exact signatures.
  • std reference — the standard library, signatures first. Go here to answer “what were the parameters again?”.
  • Specification — the formal definition: grammar, type rules, the memory model, execution. This is the advanced tier. The tour teaches; the spec defines; where they disagree, the spec wins.
  • Appendix — the error index (“you saw this message, go here”), the gotchas checklist, and the glossary.

Reading this as a website

The book renders with mdBook: mdbook serve vilan/docs gives a local live-reloading site with search and a sidebar (cargo install mdbook once). Pushes to main publish it to GitHub Pages automatically. Everything also reads fine as plain files — the site adds navigation, it doesn’t replace the markdown.

Conventions

  • Examples are complete programs unless explicitly labelled a fragment — copy, vilan build, run.
  • Every example compiles as part of the test suite (cargo test --test docs): a fenced ```vilan block must compile for the node target, ```vilan,browser for the browser target, ```vilan,norun compiles but needs external services to actually run, and ```vilan,fragment is prose-only (used sparingly, always labelled).
  • Maintenance rule: a change to std, a framework, or the language updates the affected docs page in the same commit.

Contents

Tour

ChapterCovers
Coming from JavaScriptthe three big shifts, a JS→vilan phrasebook
Hello vilanthe CLI, vilan.toml, packages & workspaces, imports
Values & typesbindings, primitives & numeric widths, strings & interpolation, tuples, collections
Functions & closuresfun, closure types, named-fn coercion, async closures and their seams, context clauses
Data & traitsstructs, enums, impl, generics & bounds, traits, derives
Control flowmatch/is, loops, ret, Option/Result idioms, ! and ?.
The memory modelvalue semantics, views, mut/own, Shared, Arena/Handle
Asyncimplicit await, async expr spawn, promises, timers
Resourcesresource, moves & loans, Drop, drop(x), Option.take, Database, OwnedNursery
Macros & constconst evaluation, derive macros, macro { … } blocks
Platformsstd layers, full-stack packages, externs, assets

Guides

ChapterCovers
Reactive statesignals, derived state, effects, ownership & disposal, turns, optimistic, Draft
Building UIview chaining, binds, events, lists, conditionals, mounting
Stylingconst typed styles, lengths/colors, dynamic values
Routingenum routes, parse/href, link, swap, navigation
Services & RPC[service]/[rpc]/[expose], Wire, mirrors, reconnection, the server side
Persistence & the serverstd::db (SQLite), the http server, files, the process
A full-stack walkthroughthe Notes app end to end — every layer meeting, quoted from a real, tested example

std reference

PageModules
collectionsList, Map, Set, Range, Iterator
option & resultOption, Result and their method sets
stringsstr, Display, Debug, Into
numbersthe sized numerics, math, random
traitscompare, default, the operator traits, Try/Lift
cellsShared, Arena/Handle
timeInstant, Duration, timers
encodingjson, wire, binary, bytes, base64
netfetch, ws
reactivethe full std::reactive API
stylethe full std::style API
rpcstd::rpc — transports, clients, frames
browserstd::dom, std::ui, std::router, std::storage
processdb, http, fs, process, rpc_server
miscio, promise, context, crypto, jwt, asset

Specification

ChapterDefines
§1 Introductionconformance, notation, processing phases
§2 Lexical structuretokens, keywords, literals, operators
§3 Grammarthe full EBNF, precedence, patterns, types
§4 Names & modulesscopes, resolution, imports, namespaces
§5 The type systemtypes, generics & inference, traits, coercions, !/?.
§6 The memory modelthe four rules, views, projections, the await rule
§7 Execution & asyncentrypoint, evaluation order, the async model
§8 Contextsambient values: run/get, coverage, injected closures
§9 Const evaluationcompile-time values, the const environment, assets
§10 Macrosattribute/derive/block macros, macro_std, splicing
§11 Platform model & manifestslayers, coloring, fences, vilan.toml
§A Appendixprecedence & keyword tables, lang items