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
| Library | What it gives you | Namespaces |
gen_collect | Generic collections: Vector, Map, Hash, Set and the rest, plus tuples. Also always loaded. | Collection, Collection.Tuple |
lang | The 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 actor | Actors with supervision, the base for programs made of cooperating agents. | System.Actor |
-lib cipher | SHA and MD5 hashes, HMAC, AES-256 encryption and Base64. | Cipher |
-lib concurrent | Structured concurrency (TaskScope, Task) and a runtime Monitor. | System.Concurrency |
-lib diags | Static analysis behind the language server: symbols, diagnostics and hover information. | System.Diagnostics |
-lib math | Arbitrary-precision and exact arithmetic. | System.Math |
-lib misc | Date parsing and formatting, and network time. | System.Time, System.Utility |
-lib regex | Regular expressions: matching, replacing, anchors, groups. | Query.RegEx |
Data and text
| Library | What it gives you | Namespaces |
-lib csv | Read and write delimited text (RFC 4180). | Data.CSV |
-lib json | Parse and build JSON, with a schema layer for typed access. | Data.JSON, Data.JSON.Scheme |
-lib json_rpc | JSON-RPC 2.0 client and server. | Data.JSON.RPC |
-lib json_stream | A streaming JSON parser for documents too large to hold as a tree. | Data.JSON.Stream |
-lib odbc | ODBC database access: connections, statements, result sets. | Database.ODBC |
-lib query | An in-memory, column-oriented SQL engine over typed tables, with joins, grouping and indexes; reads CSV, JSON, XML and archives. | Query.Structured |
-lib query_ml | Model evaluation results as Query.Structured tables. | Query.Structured.ML |
-lib query_odbc | A table or a query in a real database, read as a table. | Query.Structured.Odbc |
-lib query_server | Publish tables over HTTP, read-only, with a SQL endpoint. | Query.Structured.Server |
-lib query_vision | A folder of images, and what a detector found in them, as tables. | Query.Structured.Vision |
-lib xml | Parse and build XML. | Data.XML |
Web and networking
| Library | What it gives you | Namespaces |
-lib net | HTTP/1.1 and HTTPS clients, URL and response types, and a downloader. | Web.HTTP |
-lib net_h2 | An HTTP/2 client with multiplexed streams. | Web.HTTP |
-lib net_quic | An HTTP/3 (QUIC) client. | Web.HTTP |
-lib net_server | An HTTP server framework: routes, static files, an MCP transport and OAuth helpers. | System.IO.Net.OAuth, Web.HTTP.Server, Web.HTTP.Server.MCP |
-lib rss | An RSS 2.0 feed reader. | Web.RSS |
-lib web_server | A small embedded web server with typed access to the request. | Web.Server |
LLMs, agents and inference
| Library | What it gives you | Namespaces |
-lib actor_agents | Run an agent as a supervised actor. | System.Actor |
-lib agent | A provider-neutral tool-use loop: an agent that calls the functions you give it. | API.Agent |
-lib ai_hub | Download models from the Hugging Face Hub into a local cache. | System.AI.Hub |
-lib anthropic | Anthropic Messages API client. | API.Anthropic |
-lib gemini | Google Gemini client, including tuning and corpora. | API.Google.Gemini, API.Google.Gemini.Corpus, API.Google.Gemini.Tuning |
-lib inference | A client for HTTP model-inference servers. | API.Inference |
-lib llm_util | Prompt templates, token estimates, context windows and JSON Schema validation for model calls. | API.LlmUtil |
-lib mcp | Model Context Protocol server and client. | API.MCP |
-lib models | Backend-neutral inference types shared by the model libraries. | API.Models |
-lib ollama | Ollama client, for models that run on your own machine. | API.Ollama |
-lib onnx | ONNX Runtime inference for pre-trained models. Experimental: the API may change. | API.Onnx |
-lib openai | OpenAI chat, responses, audio, embeddings, vision and more. | API.OpenAI, API.OpenAI.Audio, API.OpenAI.Chat, API.OpenAI.Responses, API.OpenAI.Tuning |
-lib opencv | OpenCV computer vision: load, transform and detect in images. | API.OpenCV |
-lib rag | Retrieval-augmented generation: chunking, retrieval and grounded prompts. | System.ML.Rag |
-lib rag_adapters | Adapters that connect the RAG kit to the embedding and chat libraries. Experimental: the API may change. | System.ML.Rag |
Machine learning and statistics
| Library | What it gives you | Namespaces |
-lib ai | Classic AI: graph search, minimax and Monte Carlo tree search, optimization, reinforcement learning. | System.AI |
-lib ml | Matrices and neural networks, linear models, trees and forests, naive Bayes, nearest neighbours, clustering, SVMs, outlier detection and preprocessing. | System.ML |
-lib ml_boost | Gradient boosting for regression and classification. Experimental: the API may change. | System.ML.Boost |
-lib ml_clip | CLIP image embeddings and face-pair scoring. | System.ML.Clip |
-lib ml_cnn | Convolutional neural networks on the CPU. | System.ML.Cnn |
-lib ml_lab | Experiment support: splits, resampling and parameter sweeps. | System.ML.Lab |
-lib ml_report | Replicate statistics and a report builder for a study. | System.ML.Report |
-lib ml_timeseries | Time series: transforms, forecasters, ARIMA and forecast evaluation. Experimental: the API may change. | System.ML.TimeSeries |
-lib ml_vector | A local vector index: store embeddings, ask for the nearest. | System.ML.VectorSearch |
-lib ml_verify | Verification metrics (FAR, FRR, EER) for match decisions. | System.ML.Verification |
-lib nlp | Tokenization, stemming, TF-IDF, similarity and sentiment. | System.NLP |
-lib nlp_onnx | Sentence embeddings from BERT-family models exported to ONNX. | System.NLP.Onnx |
-lib nlp_topics | Topic modeling (LDA), quality metrics and an SVG topic report. | System.NLP.Topics |
-lib plot | Scatter, histogram, line and bar charts as standalone SVG. | System.Plot |
-lib plot_sdl | An SDL2 window for System.Plot, and PNG export. | System.Plot.SDL |
-lib stats | Descriptive statistics, distributions, t-tests and an OLS summary. | System.Stats |
-lib telemetry | Per-model, per-device inference timing and resource sampling. | System.Telemetry |
| Library | What it gives you | Namespaces |
-lib lame | MP3 encoding with LAME. | Game.SDL2.Aux |
-lib sdl2 | SDL2: 2D graphics, input, audio and windows. | Game.SDL2 |
-lib sdl_game | A 2D game framework: sprites, collisions, tilemaps, camera and scenes. | Game.Framework |
-lib sdl_gl | OpenGL 3.3 core rendering on top of SDL2. | Game.OpenGL |