Skip to main content

Standard Library

Script Core provides a minimal standard library — only essential primitives needed to run code. Extended functionality (HTTP, TLS, crypto, etc.) is provided by the Rolls ecosystem.

Philosophy

Script Core is like "C without libc" — minimal and self-contained:

In CoreWhy
console.logEssential for output
ByteStreamNeeded for bootstrap compiler
Basic fsNeeded for file-based compilation
In Rolls (Optional)Why
HTTP, TLS, WebSocketExternal dependencies
Database driversDatabase-specific
Math functionsStandard library
Crypto operationsExternal libraries

Console

console.log("Hello", 42, true);
console.error("Something went wrong!");

Outputs values to stdout/stderr with automatic formatting.

String

let char = String.fromCharCode(65); // "A"

ByteStream (Binary Data)

Low-level binary data manipulation for working with bytes. Used internally by the bootstrap compiler.

let stream = ByteStream.create();
ByteStream.writeU8(stream, 0xff);
ByteStream.writeU32(stream, 12345);
ByteStream.writeF64(stream, 3.14159);
ByteStream.writeString(stream, "hello");
let bytes = ByteStream.toArray(stream);

File System (Minimal)

Basic file operations for compilation:

let fs = require("fs");
let content = fs.readFileSync("file.txt");
fs.writeFileSync("out.txt", "Hello!");
fs.writeBinaryFile("data.bin", bytes);

Module Loading

Script supports both ES modules and require-style loading:

// ES Modules (recommended)
import { something } from "./my-module";
export function myFunc() {
/* ... */
}

// CommonJS-style (also supported)
let fs = require("fs");
let myModule = require("./my-module");

Future: Rolls Ecosystem

Extended functionality will be provided by the Rolls ecosystem:

RollPurpose
@rolls/httpHTTP/1.1, HTTP/2 server
@rolls/tlsTLS encryption
@rolls/fsRich file system operations
@rolls/jsonJSON parse/stringify
@rolls/mathMath functions
@rolls/cryptoCryptographic operations
@rolls/dbDatabase drivers

See the Architecture for more details on the Rolls ecosystem.