Status: Authoritative Specification Version: 2.0.0 Last Updated: 2026-07-15 Related Documents: 01 Language Spec · 09 Runtime Design · 13 CLI Spec
graph TD
STDLIB["techscript_stdlib"]
IO["io"]
MATH["math"]
STRING["string"]
FILE["file"]
WEB["web"]
TIME["time"]
RANDOM["random"]
JSON_MOD["json"]
COLLECTIONS["collections"]
STDLIB --> IO
STDLIB --> MATH
STDLIB --> STRING
STDLIB --> FILE
STDLIB --> WEB
STDLIB --> TIME
STDLIB --> RANDOM
STDLIB --> JSON_MOD
STDLIB --> COLLECTIONS
style STDLIB fill:#4a9eff,color:#fff
io.print(val), io.println(val) (alias: say), io.eprint(val), io.eprintln(val), io.read_line() (alias: ask).
Constants: PI, E, TAU, INF, NAN.
Functions: abs(x), sqrt(x), pow(b, e), sin(x), cos(x), tan(x), floor(x), ceil(x), round(x), min(a, b), max(a, b), clamp(x, min, max).
upper(s), lower(s), trim(s), split(s, sep), join(list, sep), replace(s, from, to), contains(s, sub), starts_with(s, prefix), ends_with(s, suffix), chars(s).
read(path), write(path, content), append(path, content), exists(path), delete(path), list_dir(path), size(path). All paths target .txs files or local project items.
Page builder API for HTML output.
web.page(), page.title(t), page.h1(t), page.p(t), page.style(css), page.script(js), page.html(), page.save(path), page.run().
now(), now_ms(), sleep(secs), format(timestamp, fmt), clock().
random(), random_int(min, max), random_choice(list), shuffle(list), seed(n).
parse(text), stringify(value).
sort(list), reverse(list), filter(list, fn), map(list, fn), reduce(list, fn, init), zip(a, b), enumerate(list).
Standard library helper methods can be accessed directly on variables:
make words = "hello world".split(" ")
make doubles = [1, 2, 3].map(build(x) { return x * 2 })
- API Parity: Standard library functions match the behavior and arguments of Version 1 APIs.
- Unified keyword integration: Standard library methods that accept callback functions (e.g.,
collections.map) are fully compatible with closures defined using both the unifiedbuildand deprecatedfunkeywords.
- Standard library file APIs (
file.read,file.write) accept and process paths referencing.txsfiles. - Example program using
collections:// Version 2.0 standard library call from collections import filter make odds = filter([1, 2, 3], build(x) { return x % 2 != 0 })
- Decoupled stdlib: The standard library is implemented as a Rust crate (
techscript_stdlib) separate from the interpreter core. This makes it easy to add new modules without modifying the execution core. - Map insertion preservation: The JSON module maps serialized objects directly to
indexmap::IndexMap, matching the behavior of Python dictionaries in Version 1.
- v2.1: Optimize collections implementation using VM bytecode operations to avoid closure scope cloning.
- v2.2: Add type signatures to all standard library modules to support static analysis.