RuneScript

v0.7 in progressEarly development

A strict, statically typed language with ActionScript roots

RuneScript keeps ActionScript's package, trace, int/uint, try/catch and access modifiers, moves to a C-family syntax, and checks every type before your program runs. It runs as a standalone CLI implemented in Go, and compiles to a JavaScript module for the web with the same strict typing.

Implemented in
Go 1.25+
Typing
Static, explicit
Runs as
CLI, JavaScript, WebAssembly
// The smallest complete RuneScript program.
package main;

protected int main() {
    trace("Hello, RuneScript!");
    return 0;
}
$ runescript run hello.rsc
Hello, RuneScript!

Familiar shape, stricter rules

If you've written ActionScript, Java, C# or TypeScript, RuneScript reads the way you expect. It just refuses to guess.

  • Types first, C-family syntax

    Write public int add(int a, int b). Every function starts with an access modifier, types come before names, and semicolons are required.

  • Strict by default

    Nothing is implicitly any. Signed and unsigned integers never mix silently, and conditions must be bool.

  • No silent overflow

    Integer arithmetic is exact. Overflow and division by zero stop the program with a located runtime error instead of wrapping.

  • Errors that point at the problem

    Every diagnostic has a stable code, a line and column, the source line with a caret, and help text that says how to fix it.

  • Functions as values

    Function types like int(int, int), lambdas, callbacks, nested functions, prototypes, and functions that return functions.

  • Docs that compile

    Every program in the guide is compiled by the test suite, and every example's output is checked. If the docs drift, the build fails.

Rejected at compile time

Mistakes surface before the program runs

Assigning a signed value to a uint is a compile-time error, not a silent wraparound. The checker tells you exactly where, and what to do about it.

  • Stable error codes, such as ASX-TYPE-004
  • line:col positions, with the source line and a caret
  • Help text with a concrete fix
Browse every error code
signedness_error.rsc
package examples.errors;

protected int main() {
    sint signedValue = -10;
    uint unsignedValue = signedValue; // expect: ASX-TYPE-004 9:26
    return 0;
}
$ runescript check signedness_error.rsc
examples/signedness_error.rsc:9:26: error ASX-TYPE-004: Cannot assign signed integer 'sint' to unsigned integer 'uint'.
        uint unsignedValue = signedValue; // expect: ASX-TYPE-004 9:26
                             ^^^^^^^^^^^
  help: Use an explicit checked conversion, (uint) x, or change the destination type.

Coming from ActionScript 3

RuneScript is inspired by AS3 but isn't source-compatible with it. Declarations put the type first, and there's no function or var.

ActionScript 3

Greeter.as
package {
    public class Greeter {
        public function sayHi(message:String, times:int):void {
            for (var i:int = 0; i < times; i++) {
                trace(message);
            }
        }
    }
}

RuneScript

greeter.rsc
package main;

public void sayHi(string message, int times) {
    for (int i = 0; i < times; i++) {
        trace(message);
    }
}

protected int main() {
    sayHi("hi", 2);
    return 0;
}
How AS3 and RuneScript treat integers
CodeActionScript 3RuneScript
var u:uint = -1;Becomes 4294967295Compile error ASX-TYPE-007
uint ← int variableConverted silentlyCompile error ASX-TYPE-004
int + uintConverted silentlyCompile error ASX-TYPE-011
int.MAX_VALUE + 1Wraps to a negative numberRuntime error ASX-RUN-002
7 / 23.53 (integer division)
Full comparison

Where it stands

RuneScript is small on purpose. A feature counts as done only when tests show it working.

Works now

  • Packages and access-modified functions
  • int / sint, uint, float / float32 / float64, bool, string, void
  • if, while, for, for each, break, continue, return
  • Function types, lambdas, callbacks
  • use "std:string" (Go's strings package, with split, join, and callbacks)
  • Strings: + and $"{count} files"; char; Array<T> with checked indexing
  • int8 … uint64, hex and binary literals, bit operators
  • use "std:math", with bit-identical results on both targets
  • Structs with value semantics, methods, and constructors
  • SemVer metadata for module files
  • Go closure execution for the CLI
  • Graphics with raylib on desktop and in the browser
  • Classes: fields, methods, constructors; objects by reference with new
  • Multi-file programs: use "pkg" and use "./file"
  • Files, input, and arguments: use "std:fs", "std:io", "std:process", "std:path"
  • Data: use "std:json", "std:csv", "std:matrix", "std:semver"
  • Checked conversions: (int) 64.3, (float) "64.7"
  • throw, try / catch / finally, catchable runtime errors
  • Located compile-time and runtime errors
  • Compiles to JavaScript (runescript build), with source maps
  • Calls JavaScript through extern, checking every value that comes back
  • Warnings, with -Werror and --allow
  • Live reload: runescript dev, run --watch
  • Web pages: checked HTML/SVG templates, $foreach lists, runes (signals), events
  • Editors: VS Code, Vim, Neovim, Emacs, through the language server (runescript lsp)

Planned

  • Class inheritance and interfaces
  • Graphics audio
  • Workspace-wide rename
See the roadmap

Run your first program

You need Go 1.25 or newer. Build the CLI, then run any example.

  1. Get the source

    $ git clone https://github.com/AurielSolaris/runescript.git && cd runescript
  2. Build the CLI

    $ go build -o runescript ./cmd/runescript
  3. Run a program

    $ ./runescript run examples/hello.rsc
    Hello, RuneScript!