RuneScript

RuneScript documentation

A practical tour of the RuneScript features that exist today. Every complete program in these pages is compiled by the test suite, so if one stops compiling, the build fails.

The guide

  1. Getting startedBuild the CLI, run a program, run --watch.
  2. Program structurePackages, comments, main.
  3. Types and variablesInt, uint, bool, string, assignment.
  4. OperatorsArithmetic, comparison, logic.
  5. Control flowIf, while, for, break, continue.
  6. FunctionsParameters, return values, recursion.
  7. Output with traceTo print one string built from several values, join them with + or use an interpolated string such as $"{name} is {age}" ([chapter…
  8. Diagnostics referenceEvery error and warning code, -Werror, --allow.
  9. Coming from ActionScript 3AS3 lets you write if (count) or if (name). RuneScript requires a bool, so write if (count != 0).
  10. Standard library: std:stringGo's strings, in RuneScript.
  11. Compiling to JavaScriptRunescript build, how strict typing is kept, calling JavaScript with extern, and live reload with runescript dev.
  12. Packages and filesUse, multi-file programs, visibility.
  13. Floats and conversionsFloat, float32, float64, (int) x.
  14. Errors: throw, try, catch, finallyThrow, try, catch, finally, and catching runtime errors.
  15. Web pages with rune:domComponents, checked HTML and SVG templates, runes, events, $if, renderApp.
  16. Text and lists: joining strings, char, and arraysJoining strings with +, interpolated strings $"…", char, and Array<T>.
  17. No null, no any, no genericsWhy, and how to use false where other languages use null.
  18. Numbers in depth: widths, literals, bits, and std:mathInt8 … uint64, hex and binary literals, bit operations, std:math.
  19. StructsDeclaring, building, and copying value types.
  20. Files, input, and outputStd:io, std:process, std:fs, std:path, and a Brainfuck interpreter.
  21. JSON: std:jsonStd:json: parsing, reading with checked functions, building, and writing JSON.
  22. CSV, matrices, and versionsStd:csv, std:matrix, and std:semver.
  23. EditorsVS Code, Vim, Neovim, and Emacs, and the language server runescript lsp.
  24. ClassesFields, methods, constructors, this, and objects as references.
  25. Graphics on desktop and in the browserWindows, drawing, input, textures, and widgets.

Not yet available: class inheritance, struct methods, and objects, arrays, structs, or callbacks across the JavaScript boundary. Full JavaScript compatibility isn't promised yet; strict checking is. Reserved keywords give a clear “not implemented yet” error. See theroadmap.