flarisvm hello.fls

Flaris
a lightweight
async scripting language

Fast, embeddable, and concurrent by design. Flaris combines fiber-based async/await with a compact bytecode VM written in C - familiar syntax, deterministic execution, and a 35-module standard library.

Fiber-based concurrency Static analyzer FFI / C plugins Embeddable VM ARM64 & x86_64 JIT Package manager Windows · Linux · MacOS Portable bytecode Null safety Optional typing
↓ Download View examples Documentation -
hello.fls
// A quick taste of Flaris

fn async fetchData(url:string):object {
    var resp = await Http.Get(url);
    return Json.Parse(resp.body);
}

fn async Main() {
    let data = await fetchData("https://api.example.com/data");
    Console.WriteLine("Received: " + data.toString());

    // Fibers run concurrently on the cooperative scheduler
    let jobs = [
        fetchData("https://api.example.com/a"),
        fetchData("https://api.example.com/b"),
    ];
    foreach (let j in jobs) await j;
    return 0;
}

Why Flaris

Built for speed, designed for clarity

Flaris sits in the same performance tier as Lua - faster than CPython and QuickJS on compute-heavy workloads, and matching Lua on array-intensive benchmarks. First-class fiber concurrency, mandatory static analysis, and native C integration, with no external dependencies.

Bytecode VM

Compiles .fls source to compact .flx bytecode. Execute pre-compiled files for fast cold-start - compile once, deploy anywhere.

🔀

Fiber Concurrency

Lightweight fibers with async/await and cooperative scheduling. No threads, no data races - deterministic execution always.

🔍

Static Analyzer

A multi-pass analyzer (10 passes) catches type errors, unused variables, unreachable code, and flow issues before runtime.

🔌

FFI / C Plugins

Load native shared libraries at runtime and call C functions directly. Wrap performance-critical code in a thin C layer with full access to the VM API.

📦

35 Stdlib Modules

HTTP, JSON, Regex, Crypto, Graphics, File I/O, Networking, and more - batteries included without external dependencies.

🛡️

Safe by Default

Unsafe features (FFI, raw memory, eval) require the explicit -u flag. Any module import can be pinned to a SHA-256 fingerprint - if the bytecode doesn't match, the VM halts before execution. Production deployments stay locked down.

🌐

Cross-Platform Bytecode

Compile on macOS, run on Linux ARM64 or Windows without recompiling. Portable .flx files run on any supported target.

🧩

Embeddable VM

Drop flarisvm into your C application. Script your game, tool, or server with a minimal surface area.


FFI Guide -
🖥️

Familiar Syntax

Borrows from JavaScript and C# - let/var, classes, lambdas, modules. Short adoption time from most modern languages.

🚀

JIT Compiler

Functions declared with fn hot compile to native ARM64 or x86-64 on first call. Loop-heavy math and array work runs > 10x faster than the interpreter - same source, add -j to enable.

🪶

Low Memory Footprint

SLAB allocator, SSO strings (≤15 chars inline), and compact bytecode keep heap pressure minimal. The full VM, compiler, and standard library weigh in around 1 MB - ideal for embedded targets and resource-constrained environments.

🏷️

Optional Typing

Annotate as much or as little as you want. The analyzer infers types where omitted and enforces them where declared. Null unions (string|nil) and null-coalescing (??) are built into the language.

📦

Package Manager

flarispm installs packages from any git repository - no central registry needed. Written in Flaris itself. One command to add, compile, and import a library.


Get flarispm →

Code Examples

See Flaris in action

From classes to fibers, from HTTP to native FFI - a few patterns to get started.

class Animal {
    fn Constructor(n: string) { this.name = n; }
    fn Speak() { Console.WriteLine(this.name, " makes a sound."); }
}

class Dog : Animal {
    fn Constructor(n: string) { this.name = n; }
    fn Speak() { Console.WriteLine(this.name, " barks."); }
}

fn Main() {
    let d: instance = new Dog("Rex");
    d.Speak();  // Rex barks.
    return;
}
fn async fetch(id: int): int {
    Fiber.Sleep(id * 10);
    return id * id;
}

fn async Main() {
    // Spawn three fibers - they run cooperatively
    let a: fiber = fetch(3);
    let b: fiber = fetch(1);
    let c: fiber = fetch(2);

    // await collects each result
    Console.WriteLine(await a, await b, await c);  // 9 1 4
    return;
}
import { Http } from library("Http", "1.0");

fn Main() {
    // Simple HTTP GET
    let resp = Http.Get("http://httpbin.org/json");
    Console.WriteLine("status: ", resp.status);

    let data = Json.Parse(resp.body);
    Console.WriteLine(data.slideshow.title);

    // POST with JSON body
    let payload = Json.Stringify({ name: "Flaris", version: 1 });
    let post = Http.Post("http://httpbin.org/post", payload,
                 { "Content-Type": "application/json" });
    Console.WriteLine("posted, status: ", post.status);
    return;
}
fn divide(a: int, b: int): int {
    if (b == 0) throw(1, "division by zero");
    return a / b;
}

fn Main() {
    try {
        Console.WriteLine(divide(100, 10));  // 10
        Console.WriteLine(divide(100, 0));   // throws
    } catch (e) {
        Console.WriteLine("caught: ", e.Error);
    } finally {
        Console.WriteLine("cleanup");
    }

    // Null coalescing
    let raw: string|nil = nil;
    let val: string|nil = raw ?? "default";
    Console.WriteLine(val);  // default
    return;
}
// Tight numeric loops can compile to native ARM64 at runtime.
// Mark the function with 'fn hot' and run with -j:
//   flarisvm -j compute.fls

fn hot sum(n: int): int {
    var s: int = 0;
    for (var i: int = 0; i < n; i++) {
        s = s + i;
    }
    return s;
}

fn Main() {
    Console.WriteLine(sum(1000));  // 499500
    return;
}

// Measured over 10 000 calls on Apple M-series:
//   interpreter   1502 ms
//   JIT              8 ms   -  ~180× faster
//
// The compiler analyzes type annotations to decide eligibility.
// Only pure integer/float math with typed locals qualifies.
// Everything else falls back to the interpreter transparently.
// Run:  flarisvm --check app.fls
// The static analyzer runs 9 passes and reports early:

fn Main() {
    let x: int = "hello";        // ← error: type mismatch
    let y: int = 42;

    return;
    Console.WriteLine("unreachable");  // ← warning: dead code
}

// app.fls:4:24: 1000: Type mismatch for 'x' (expected compatible with declared type).
// app.fls:8:35: 2006: Unreachable code.

Example Collection

Runnable .fls files - each covering a distinct language feature or use case.

01 Hello Console
02 Arrays, Objects & Functions
03 JSON Transform
04 Files & Hash Integrity
05 Classes & Reflection
06 Fibers & Async Pipeline
07 Command Arguments
08 Debugging
09 Switch & Control Flow
10 Error Handling & Guard
11 Math Utilities
12 Module Imports
13 Graphics
14 FFI / C Extensions

Standard Library

35 modules, zero dependencies

Everything from JSON and cryptography to regex and compression is built in. No package manager required for the essentials.

Core

  • Console
  • Math
  • String
  • Time
  • Timers
  • Convert
  • Util

Data

  • Json
  • Regex
  • Hash
  • Buffer
  • Crypto
  • Collections
  • Compress

I/O & Files

  • File
  • Path
  • Directory
  • Stream
  • Os

Networking

  • HttpUtil
  • Net

Concurrency

  • Fiber
  • Scheduler
  • Event

Reflection

  • Array
  • Object
  • Class
  • Type

System

  • Memory
  • Ffi
  • Exception
  • Debug
  • FileWatch
  • VM

Graphics

  • Gfx

Libraries

34 add-on libraries, ready to import

Install a library once into your per-user libs folder — ~/.flaris/libs on macOS and Linux, %USERPROFILE%\.flaris\libs on Windows — and import it by name from any script, no --libs flag needed. (You can also just drop a .flx next to a script for one-off use.) Each library ships source and pre-compiled bytecode. Libraries marked -u require the unsafe flag at runtime. Download the .fls source for inline documentation and usage examples.

AI Ollama AI client - chat, streaming, JSON-mode, tool/function calling, vision input, embeddings, async, and model management. Requires a local Ollama server or an HTTP proxy for cloud endpoints.
import * from library("https://www.flaris-lang.org/libs/AI.flx", "1.0")
import * from library("AI", "1.0")
Audio Audio processing library: WAV I/O, envelope, gain & dynamics, and effects. Extends the Signals DSP base.
import * from library("https://www.flaris-lang.org/libs/Audio.flx", "1.0")
import * from library("Audio", "1.0")
BigInt Arbitrary-precision integer arithmetic - add, mul, pow, mod, bitwise (and/or/xor/not/shifts), byte conversion, no overflow.
import * from library("https://www.flaris-lang.org/libs/BigInt.flx", "1.0")
import * from library("BigInt", "1.0")
BinaryIO Binary serialization - BinaryWriter/Reader, streaming and file variants. Little-endian default.
import * from library("https://www.flaris-lang.org/libs/BinaryIO.flx", "1.0")
import * from library("BinaryIO", "1.0")
BitConverter Bit-level and byte-order conversion between numeric types.
import * from library("https://www.flaris-lang.org/libs/BitConverter.flx", "1.0")
import * from library("BitConverter", "1.0")
Cache LRU cache with configurable capacity and optional TTL - O(1) lookup, automatic eviction, hit/miss stats, JSON persistence (Save/Load), async GetOrSet.
import * from library("https://www.flaris-lang.org/libs/Cache.flx", "1.0")
import * from library("Cache", "1.0")
CSV RFC 4180 compliant CSV parser and serializer - quoted fields, custom delimiters, TSV support, type inference, formula-injection escaping.
import * from library("https://www.flaris-lang.org/libs/CSV.flx", "1.0")
import * from library("CSV", "1.0")
Complex Complex number arithmetic - add, mul, div, magnitude, phase, polar form.
import * from library("https://www.flaris-lang.org/libs/Complex.flx", "1.0")
import * from library("Complex", "1.0")
Config TOML, YAML and .env configuration parser - strings, ints, floats, bools, arrays, sections, dotted keys, ${VAR} interpolation.
import * from library("https://www.flaris-lang.org/libs/Config.flx", "1.0")
import * from library("Config", "1.0")
ConsoleMenu Interactive terminal menus with keyboard navigation and selection callbacks.
import * from library("https://www.flaris-lang.org/libs/ConsoleMenu.flx", "1.0")
import * from library("ConsoleMenu", "1.0")
Datetime Parse, format, compare, and do arithmetic on dates, times, and durations - including timezones and business-day arithmetic (holidays).
import * from library("https://www.flaris-lang.org/libs/Datetime.flx", "1.0")
import * from library("Datetime", "1.0")
Decimal Fixed-point decimal math for financial and precision-sensitive calculations.
import * from library("https://www.flaris-lang.org/libs/Decimal.flx", "1.0")
import * from library("Decimal", "1.0")
Graph Directed/undirected weighted graph - BFS/DFS, shortest-path (Dijkstra, A*, Bellman-Ford, Floyd-Warshall), MST (Kruskal, Prim), connectivity & components. Supports BigInt/Decimal weights.
import * from library("https://www.flaris-lang.org/libs/Graph.flx", "1.0")
import * from library("Graph", "1.0")
Graphics 2D software renderer - draw lines, shapes, sprites, and export PNG.
import * from library("https://www.flaris-lang.org/libs/Graphics.flx", "1.0")
import * from library("Graphics", "1.0")
Http HTTP/1.1 client - GET, POST, fiber-based async, cookie jar, multipart form builder, retry with backoff. Plain HTTP over TCP; add the Https library for TLS.
import * from library("https://www.flaris-lang.org/libs/Http.flx", "1.0")
import * from library("Http", "1.0")
Https -u HTTPS client - injects an OpenSSL TLS transport (via FFI) into the Http engine, so all framing, chunked decoding, redirects, and cookies are shared. Certificate verification on by default. Requires -u flag.
import * from library("https://www.flaris-lang.org/libs/Https.flx", "1.0")
import * from library("Https", "1.0")
Jwt JSON Web Tokens - issue and verify compact JWTs (HS256, HS512, and EdDSA/Ed25519) in Base64url format.
import * from library("https://www.flaris-lang.org/libs/Jwt.flx", "1.0")
import * from library("Jwt", "1.0")
Linq Functional collection queries - map, filter, reduce, groupBy, orderBy, distinctBy, minBy/maxBy, countBy, stats (median, stddev, percentile).
import * from library("https://www.flaris-lang.org/libs/Linq.flx", "1.0")
import * from library("Linq", "1.0")
Logger Structured leveled logging - debug/info/warn/error with timestamps, sinks (stdout/file/syslog), JSON output, and size-based file rotation.
import * from library("https://www.flaris-lang.org/libs/Logger.flx", "1.0")
import * from library("Logger", "1.0")
Lexer General-purpose configurable lexer - tokenizes any source string with fluent rule builder. Words, numbers, quoted strings, line/block comments, keywords, multi-char operators, line/col tracking.
import * from library("https://www.flaris-lang.org/libs/Lexer.flx", "1.0")
import * from library("Lexer", "1.0")
Postgres -u PostgreSQL client via native FFI - query, params, transactions. Requires pg_ffi.c and -u flag.
import * from library("https://www.flaris-lang.org/libs/Postgres.flx", "1.0")
import * from library("Postgres", "1.0")
Process Subprocess management - run external programs, capture stdout/stderr, wait for exit.
import * from library("https://www.flaris-lang.org/libs/Process.flx", "1.0")
import * from library("Process", "1.0")
Promise Promise chaining, combinators (all, race, any), and error propagation.
import * from library("https://www.flaris-lang.org/libs/Promise.flx", "1.0")
import * from library("Promise", "1.0")
QRCode Pure-Flaris QR code generator - versions 1–10, error correction L/M/Q/H, SVG and PNG output.
import * from library("https://www.flaris-lang.org/libs/QRCode.flx", "1.0")
import * from library("QRCode", "1.0")
Redis -u Redis client via native FFI - strings, hashes, lists, pub/sub. Requires redis_ffi.c and -u flag.
import * from library("https://www.flaris-lang.org/libs/Redis.flx", "1.0")
import * from library("Redis", "1.0")
Router -u HTTP server router with middleware pipeline - path params, method matching, path-safe static file serving, JWT/CORS/rate-limit helpers. Requires -u flag.
import * from library("https://www.flaris-lang.org/libs/Router.flx", "1.0")
import * from library("Router", "1.0")
Signals Digital signal processing - FFT, filters, synthesis, statistics. Float arrays in [-1.0, 1.0]. Base class for Audio.
import * from library("https://www.flaris-lang.org/libs/Signals.flx", "1.0")
import * from library("Signals", "1.0")
SQLite -u SQLite client via native FFI - query, params, transactions. Requires sqlite_ffi.c and -u flag.
import * from library("https://www.flaris-lang.org/libs/SQLite.flx", "1.0")
import * from library("SQLite", "1.0")
StringBuilder Efficient incremental string construction - append, prepend, replace, join.
import * from library("https://www.flaris-lang.org/libs/StringBuilder.flx", "1.0")
import * from library("StringBuilder", "1.0")
Template Mustache-style template engine - compile once, render with variables, conditionals, and loops.
import * from library("https://www.flaris-lang.org/libs/Template.flx", "1.0")
import * from library("Template", "1.0")
Test Unit test framework - suites, beforeEach/afterEach, assertions (eq, deepEq, throws), skip support.
import * from library("https://www.flaris-lang.org/libs/Test.flx", "1.0")
import * from library("Test", "1.0")
Treemap Sorted key-value map - keys in ascending order, O(log n) lookup/insert/delete, range queries O(log n + k).
import * from library("https://www.flaris-lang.org/libs/Treemap.flx", "1.0")
import * from library("Treemap", "1.0")
WebSocket -u WebSocket client (RFC 6455) - text/binary frames, ping/pong, clean close. ws:// and wss:// (built-in TLS). Requires -u flag.
import * from library("https://www.flaris-lang.org/libs/WebSocket.flx", "1.0")
import * from library("WebSocket", "1.0")
XML XML parser and builder - parses to node tree, elements, attributes, CDATA, and entity references.
import * from library("https://www.flaris-lang.org/libs/XML.flx", "1.0")
import * from library("XML", "1.0")

Downloads

Get Flaris

One command installs flarisvm and flarispm and adds them to your PATH.

macOS · Linux
$ curl -fsSL https://www.flaris-lang.org/install.sh | sh
Windows (PowerShell)
PS> iwr -useb https://www.flaris-lang.org/install.ps1 | iex

Installs to ~/.flaris/bin/ by default. Override with FLARIS_HOME=/your/path. Or download individual binaries below.

VS Code Extension flaris-0.3.0.vsix Syntax highlighting · Inline errors · Tasks ↓ Download .vsix macOS flarisvm ARM64 · Apple Silicon ↓ Download Linux flarisvm x86_64 ↓ Download Linux flarisvm ARM64 ↓ Download Windows flarisvm.exe x86_64 · MSYS2 clang64 ↓ Download
Install VS Code extension
# Download from www.flaris-lang.org/vsix/ then install from command line
$ code --install-extension flaris-0.3.0.vsix

# Or in VS Code: Extensions › ··· menu › "Install from VSIX..."
Getting started
# Run your first program
$ ./flarisvm hello.fls

# Compile to bytecode, then execute
$ ./flarisvm -c hello.fls hello.flx
$ ./flarisvm -e hello.flx

Security

Every release is signed

Flaris bytecode (.flx) carries an embedded Ed25519 signature. The official standard library is signed with the Flaris signing key, and the matching public key is compiled into the runtime as a trust anchor - so signed code verifies with nothing to download or configure. A tampered .flx fails to load; run with --require-signed to refuse anything not signed by a trusted key.

Official Ed25519 public key
flaris-official  b6e2237413be79854985a1d4650ddefca8bc9c517964e6b9814b887bc6b779be

This is the canonical reference. Confirm your install matches it: the key shown when you inspect a library, the key compiled into your runtime, and the value above should all be identical. If they agree, the artifact was signed by the official Flaris key.

Verify a library
# Inspect any .flx - the signer and trust status are in the header
$ flarisvm -d ~/.flaris/libs/Jwt.flx
  Signature : Ed25519 (valid, trusted signer)
  Signed by : b6e2237413be79854985a1d4650ddefca8bc9c517964e6b9814b887bc6b779be

# Enforce signatures: refuse unsigned or untrusted bytecode
$ flarisvm --require-signed -e app.flx

valid, trusted signer means the embedded key matched a trusted key; valid, untrusted signer means the signature is good but the key is not trusted (add it to ~/.flaris/trusted_keys to trust a third-party publisher); INVALID means the file was altered after signing.


Package Manager

Extend Flaris with flarispm

flarispm is the official Flaris package manager - written entirely in Flaris itself. Install libraries from any public or private git repository in one command. No central registry. No build system. Just git, bytecode, and --libs.

All platforms flarispm.flx Signed portable bytecode · the only artifact you need ↓ Download .flx

flarispm ships as a single signed .flx - nothing else to download. flarisvm verifies its flaris-lang.org signature on every run, so you can trust it regardless of how it reached you. Run it with flarisvm -e flarispm.flx, or add a short alias.

Setup
# Verify the download is the official, untampered build
$ flarisvm --sig-info flarispm.flx
signed|trusted|b6e2…79be|flaris-lang.org

# macOS / Linux - alias so 'flarispm' just works
$ mkdir -p ~/.flaris/bin && cp flarispm.flx ~/.flaris/bin/
$ echo "alias flarispm='flarisvm -e ~/.flaris/bin/flarispm.flx'" >> ~/.zshrc

# Windows - doskey / a one-line .bat that calls: flarisvm -e flarispm.flx %*
C:\> copy flarispm.flx C:\tools\flaris\
Install and use a package
# Initialise a project manifest
$ flarispm init

# Add any package from GitHub (or any git host)
$ flarispm add https://github.com/stefansolid/flaris-test-package

# Run with the installed packages in scope
$ flarisvm --libs='./flaris_packages' myapp.fls
myapp.fls
import { Greet } from library("Greet", "1.0");

fn Main() {
    Greet.Hello("Stefan");   // Hello, Stefan!
    Greet.Shout("it works"); // IT WORKS!!!
}
flarispm init Create flaris.json in current directory
flarispm add <url> [version] Clone, compile and register a package
flarispm install Install all dependencies from flaris.json
flarispm remove <url> Remove a package and its compiled files
flarispm list Show installed packages and their status
flarispm update [url] Pull latest and recompile (all or one)
flarispm version Print flarispm version

Documentation

Learn everything

Full language specification, standard library reference, and FFI guide - all maintained alongside the source.

Language Guide

Read top-to-bottom introduction: variables, classes, fibers, async/await, and the module system.


guide.md -

Language Reference

Full CLI flags, type system spec, built-in functions, operator precedence, VM limits, and stdlib API tables.


reference.md -

FFI Guide

Write C plugins, expose functions to Flaris, marshal types, and build high-performance native extensions.


ffi.md -

Required header for building FFI plugins:

↓ ffi_object.h