Libraries

62 libraries, generated from core/compiler/build_libs.sh and the sources. Pass them to obc -lib; a library's own dependencies are not added for you. API reference.

obc -src app.obs -lib json,net,cipher

In practice

JSON

use Data.JSON;

class Main {
  function : Main(args : String[]) ~ Nil {
    root := JsonParser->TextToElement("{\"name\": \"Ada\", \"langs\": [\"en\", \"fr\"], \"age\": 36}");
    name := root->Get("name")->GetString();
    age := root->Get("age")->GetInt();
    "{$name} is {$age}"->PrintLine();

    doc := JsonElement->New(JsonElement->JsonType->OBJECT);
    doc->Insert("ok", true);
    doc->Insert("count", 3);
    doc->ToString()->PrintLine();
  }
}
$ obc -src json.obs -lib json
$ obr json.obe
Ada is 36
{"count":3,"ok":true}

SQL

use Query.Structured;

class Main {
  function : Main(args : String[]) ~ Nil {
    sales := Table->New("sales", ["region", "qty"]);
    Add(sales, "east", 10);
    Add(sales, "west", 4);
    Add(sales, "east", 3);
    result := sales->Query("select region, sum(qty) as total from sales group by region");
    result->ToCsv()->Print();
  }

  function : Add(table : Table, region : String, qty : Int) ~ Nil {
    row := table->Insert();
    row->Set("region", region);
    row->Set("qty", IntRef->New(qty));
  }
}
$ obc -src query.obs -lib query,misc,net,json,regex,xml,csv,cipher
$ obr query.obe
region,total
east,13
west,4

Machine learning

use System.ML;

class Main {
  function : Main(args : String[]) ~ Nil {
    x := Float->New[5, 1];
    y := Float->New[5, 1];
    each(i : 5) {
      x[i, 0] := i->As(Float);
      y[i, 0] := 2.0 * i->As(Float) + 1.0;
    };

    model := LinearRegression->New();
    model->Fit(x, y, true);
    c := model->GetCoefficients();
    "y = {$(c[1]):.2} x + {$(c[0]):.2}"->PrintLine();
  }
}
$ obc -src ml.obs -lib csv,ml
$ obr ml.obe
y = 2.00 x + 1.00

Threads

use System.Concurrency;

class Counter from Thread {
  @total : static : Int;
  @lock : static : ThreadMutex;

  New() {
    Parent();
  }

  function : Init() ~ Nil {
    @lock := ThreadMutex->New("lock");
  }

  method : public : Run(arg : System.Base) ~ Nil {
    each(i : 1000) {
      critical(@lock) {
        @total += 1;
      };
    };
  }

  function : Total() ~ Int {
    return @total;
  }
}

class Main {
  function : Main(args : String[]) ~ Nil {
    Counter->Init();
    workers := Counter->New[4];
    each(i : workers) {
      workers[i] := Counter->New();
      workers[i]->Execute(Nil);
    };
    each(i : workers) {
      workers[i]->Join();
    };
    Counter->Total()->PrintLine();
  }
}
$ obc -src threads.obs -lib concurrent
$ obr threads.obe
4000

Core

LibraryWhat it gives youNamespaces
gen_collectGeneric collections: Vector, Map, Hash, Set and the rest, plus tuples. Also always loaded.Collection, Collection.Tuple
langThe core classes: console, files, sockets, reflection, threads and time. Always loaded; never passed to -lib.System, System.API, System.Concurrency, System.IO, System.IO.Filesystem, System.IO.Net, System.Introspection, System.Time
-lib actorActors with supervision, the base for programs made of cooperating agents.System.Actor
-lib cipherSHA and MD5 hashes, HMAC, AES-256 encryption and Base64.Cipher
-lib concurrentStructured concurrency (TaskScope, Task) and a runtime Monitor.System.Concurrency
-lib diagsStatic analysis behind the language server: symbols, diagnostics and hover information.System.Diagnostics
-lib mathArbitrary-precision and exact arithmetic.System.Math
-lib miscDate parsing and formatting, and network time.System.Time, System.Utility
-lib regexRegular expressions: matching, replacing, anchors, groups.Query.RegEx

Data and text

LibraryWhat it gives youNamespaces
-lib csvRead and write delimited text (RFC 4180).Data.CSV
-lib jsonParse and build JSON, with a schema layer for typed access.Data.JSON, Data.JSON.Scheme
-lib json_rpcJSON-RPC 2.0 client and server.Data.JSON.RPC
-lib json_streamA streaming JSON parser for documents too large to hold as a tree.Data.JSON.Stream
-lib odbcODBC database access: connections, statements, result sets.Database.ODBC
-lib queryAn in-memory, column-oriented SQL engine over typed tables, with joins, grouping and indexes; reads CSV, JSON, XML and archives.Query.Structured
-lib query_mlModel evaluation results as Query.Structured tables.Query.Structured.ML
-lib query_odbcA table or a query in a real database, read as a table.Query.Structured.Odbc
-lib query_serverPublish tables over HTTP, read-only, with a SQL endpoint.Query.Structured.Server
-lib query_visionA folder of images, and what a detector found in them, as tables.Query.Structured.Vision
-lib xmlParse and build XML.Data.XML

Web and networking

LibraryWhat it gives youNamespaces
-lib netHTTP/1.1 and HTTPS clients, URL and response types, and a downloader.Web.HTTP
-lib net_h2An HTTP/2 client with multiplexed streams.Web.HTTP
-lib net_quicAn HTTP/3 (QUIC) client.Web.HTTP
-lib net_serverAn HTTP server framework: routes, static files, an MCP transport and OAuth helpers.System.IO.Net.OAuth, Web.HTTP.Server, Web.HTTP.Server.MCP
-lib rssAn RSS 2.0 feed reader.Web.RSS
-lib web_serverA small embedded web server with typed access to the request.Web.Server

LLMs, agents and inference

LibraryWhat it gives youNamespaces
-lib actor_agentsRun an agent as a supervised actor.System.Actor
-lib agentA provider-neutral tool-use loop: an agent that calls the functions you give it.API.Agent
-lib ai_hubDownload models from the Hugging Face Hub into a local cache.System.AI.Hub
-lib anthropicAnthropic Messages API client.API.Anthropic
-lib geminiGoogle Gemini client, including tuning and corpora.API.Google.Gemini, API.Google.Gemini.Corpus, API.Google.Gemini.Tuning
-lib inferenceA client for HTTP model-inference servers.API.Inference
-lib llm_utilPrompt templates, token estimates, context windows and JSON Schema validation for model calls.API.LlmUtil
-lib mcpModel Context Protocol server and client.API.MCP
-lib modelsBackend-neutral inference types shared by the model libraries.API.Models
-lib ollamaOllama client, for models that run on your own machine.API.Ollama
-lib onnxONNX Runtime inference for pre-trained models. Experimental: the API may change.API.Onnx
-lib openaiOpenAI chat, responses, audio, embeddings, vision and more.API.OpenAI, API.OpenAI.Audio, API.OpenAI.Chat, API.OpenAI.Responses, API.OpenAI.Tuning
-lib opencvOpenCV computer vision: load, transform and detect in images.API.OpenCV
-lib ragRetrieval-augmented generation: chunking, retrieval and grounded prompts.System.ML.Rag
-lib rag_adaptersAdapters that connect the RAG kit to the embedding and chat libraries. Experimental: the API may change.System.ML.Rag

Machine learning and statistics

LibraryWhat it gives youNamespaces
-lib aiClassic AI: graph search, minimax and Monte Carlo tree search, optimization, reinforcement learning.System.AI
-lib mlMatrices and neural networks, linear models, trees and forests, naive Bayes, nearest neighbours, clustering, SVMs, outlier detection and preprocessing.System.ML
-lib ml_boostGradient boosting for regression and classification. Experimental: the API may change.System.ML.Boost
-lib ml_clipCLIP image embeddings and face-pair scoring.System.ML.Clip
-lib ml_cnnConvolutional neural networks on the CPU.System.ML.Cnn
-lib ml_labExperiment support: splits, resampling and parameter sweeps.System.ML.Lab
-lib ml_reportReplicate statistics and a report builder for a study.System.ML.Report
-lib ml_timeseriesTime series: transforms, forecasters, ARIMA and forecast evaluation. Experimental: the API may change.System.ML.TimeSeries
-lib ml_vectorA local vector index: store embeddings, ask for the nearest.System.ML.VectorSearch
-lib ml_verifyVerification metrics (FAR, FRR, EER) for match decisions.System.ML.Verification
-lib nlpTokenization, stemming, TF-IDF, similarity and sentiment.System.NLP
-lib nlp_onnxSentence embeddings from BERT-family models exported to ONNX.System.NLP.Onnx
-lib nlp_topicsTopic modeling (LDA), quality metrics and an SVG topic report.System.NLP.Topics
-lib plotScatter, histogram, line and bar charts as standalone SVG.System.Plot
-lib plot_sdlAn SDL2 window for System.Plot, and PNG export.System.Plot.SDL
-lib statsDescriptive statistics, distributions, t-tests and an OLS summary.System.Stats
-lib telemetryPer-model, per-device inference timing and resource sampling.System.Telemetry

Graphics, games and media

LibraryWhat it gives youNamespaces
-lib lameMP3 encoding with LAME.Game.SDL2.Aux
-lib sdl2SDL2: 2D graphics, input, audio and windows.Game.SDL2
-lib sdl_gameA 2D game framework: sprites, collisions, tilemaps, camera and scenes.Game.Framework
-lib sdl_glOpenGL 3.3 core rendering on top of SDL2.Game.OpenGL