InScript is a statically-typed scripting language with built-in game modules โ physics, audio, ECS, pathfinding, networking โ designed as a readable, safe GDScript alternative.
// Physics, input, collision โ all from the standard library import "physics2d" as P import "input" as I import "camera2d" as Cam struct Player { pos: Vec2 vel: Vec2 health: int = 3 fn update(dt: float) { let move = I.axis_x() * 180.0 self.vel.x = move if I.just_pressed("jump") && self.on_ground() { self.vel.y = -400.0 } self.pos += P.step(self, dt) Cam.follow(self.pos) } } // Result type for safe error handling fn load_level(path: string) -> Result { let data = try { read_file(path) } catch e { return Err(e) } return Ok(parse_tilemap(data)) }
Full OOP with single/multi-inheritance, interfaces, mixins, operator overloading, priv/pub fields, and static members.
Match on values, ADT enum variants, Result Ok/Err, with guards, binding, and match-as-expression.
Register-based VM with 60+ opcodes, closures, generators, and source-mapped error reporting. VM and interpreter are feature-identical.
โ CompleteOptional type annotations, inference, typed function parameters, and a static analyzer that warns on type mismatches, missing returns, and exhaustive matches.
โ CompleteFirst-class generators via fn* / yield. Works in both the tree-walk interpreter and the bytecode VM path.
Physics, input, camera, audio, tilemap, particles, pathfinding (A*), ECS, FSM, networking โ 59 modules total, all accessible via import.
30+ commands including .doc module live docs, .vm mode toggle, .bytecode disassembly, and a built-in tutorial.
Language Server Protocol server (pygls-based) with completions, hover, and diagnostics. VS Code extension with syntax highlighting and snippets.
โ CompleteCode formatter (inscript fmt) and DAP debugger for VS Code step-through debugging are the top priorities for v1.1.
Browser-based InScript playground using Pyodide. Write and run InScript directly in your browser with no install needed.
๐ v1.1First-class union types (type Shape = Circle | Rect), enforced generics, and null-safe types (int?) planned for v1.2.
Native C extension for hot paths targeting 5โ15ร speedup over the current Python-based VM. Current fib(20) โ 200ms, target โ 15ms.
v1.3
The VM and tree-walk interpreter are feature-identical โ switch modes with .vm in the REPL.
let x: int = 42 let name = "Ada" // inferred const PI = 3.14159 // Destructuring let [a, b, c] = [1, 2, 3] // Null coalescing + optional chain let name = user?.profile?.name ?? "Guest" // Pipe operator 5 |> double |> add_one // = 11
fn greet(name: string = "World") -> string { return f"Hello {name}!" } // Named args, variadics fn sum(*args) { return args.reduce(fn(a,b){return a+b}) } // Closures capture by reference fn counter() { let n = 0 return fn() { n += 1; return n } }
struct Animal { name: string priv energy: float = 100.0 fn speak() { print(self.name) } } struct Dog extends Animal { fn speak() { super.speak() print("Woof!") } fn +(other) { // operator overload return Dog{ name: self.name ++ "&" ++ other.name } } }
// Result type โ no exceptions by default fn divide(a: float, b: float) -> Result { if b == 0.0 { return Err("div by zero") } return Ok(a / b) } // try-catch as expression let safe = try { risky_fn() } catch e { 0 } // Typed catch, finally try { load() } catch e: string { log(e) } finally { cleanup() }
enum Shape { Circle(r: float) Rect(w: float, h: float) } let area = match shape { case Shape.Circle(r) { 3.14159 * r * r } case Shape.Rect(w, h) { w * h } case _ { 0.0 } } // Match guards match score { case n if n >= 90 { print("A") } case n if n >= 70 { print("B") } case _ { print("C") } }
// Generator function fn* fibonacci() { let a=0; let b=1 while true { yield a; [a,b] = [b, a+b] } } // Array + dict comprehensions let evens = [x for x in 1..=20 if x%2==0] let inv = {v: k for k,v in entries(myDict)} // Rich array methods scores.filter(fn(x){return x>60}) .sorted() .take(10)
import "module" as M. All have .doc module documentation in the REPL.sin/cos/tan, log, sqrt, floor/ceil, INF, NAN, constants
split, join, regex replace, case, pad, format, template
map/filter/reduce, sort, flatten, chunk, zip, group_by
encode/decode with pretty-print and error reporting
read/write files, append, exists, list_dir, watch
int/float/choice/shuffle, seed, weighted random
now, format, parse, diff, timezones, Duration type
Set, Queue, Deque, PriorityQueue, RingBuffer, counter
match, find_all, replace, named groups, compile
sha256, sha512, hmac, md5, bcrypt, random_bytes
v4, v1, short IDs, namespace UUIDs, validation
join, split, exists, dirname, basename, glob
mkdir, rm, copy, move, permissions, stat
get/post/put/delete, headers, JSON body, timeout
SQLite: connect, query, insert, transaction, ORM-style
AABB, circle, step, resolve, raycasting, gravity
load, render, collision layer, pathfinding grid
follow, shake, zoom, pan, parallax, bounds
key_down/up/pressed, mouse, gamepad, axis mapping
play/stop, volume, music, spatial audio, effects
emitter, burst, gradient color, physics-driven
World, spawn/despawn, component query, system schedule
StateMachine, transitions, enter/exit hooks, history
A* on grid, diagonal, weighted tiles, smooth path
emit/on/off, once, wildcards, async events
GameServer/Client, UDP, sync vars, lobby, lag comp
save/load game state, slots, versioning, encryption
i18n strings, plurals, date/number formatting, RTL
v2/v3/v4, dot, cross, normalize, lerp, mat4 planned
linear, ease-in/out, spring, chain, parallel tweens
iter, template, format, color, image, atlas, animation, signal, pool, grid, bench, thread, debug, process, log, compress, url, base64, yaml, toml, csv, xml, ssl, hash, net, argparse, shader, input, scene
# Requirements: Python 3.10+, pygame 2.x pip install pygame pygls # Clone and run git clone https://github.com/authorss81/inscript cd inscript/inscript_package # Start the REPL python inscript.py --repl # Run a game example python inscript.py examples/platformer.ins # Check version python inscript.py --version # InScript 1.0.12 # Run all tests python test_comprehensive.py # 335/335 โ
> python inscript.py --repl InScript v1.0.12 โ type .help for commands >> let x = [1,2,3,4,5].filter(fn(n){return n%2==0}) >> print(x) [2, 4] >> .doc math // live docs for any module >> .vm // switch to bytecode VM >> .bytecode // show disassembly >> .tutorial // interactive tutorial
Full details: ROADMAP.md
โข Full language (types, OOP, closures, generators, matching)
โข 59 stdlib modules, all tested
โข Bytecode VM with full feature parity
โข LSP + VS Code extension
โข Enhanced REPL with 30+ commands
โข 839 tests passing (270+145+32+54+335+3)
โข 6 game examples shipping with the repo
โข Windows, macOS, Linux
โข inscript fmt code formatter
โข Debugger (step-through in VS Code)
โข pip install inscript not live yet
โข Docs site URLs still 404
โข No web playground yet
โข async/await is synchronous only
โข Generics are annotation-only (not enforced)
โข ~40ร slower than Python (C ext planned v1.3)