Skip to main content

Standard Library

The Mux standard library provides a collection of essential modules for common programming tasks. These modules are designed to be simple, efficient, and consistent with Mux's philosophy of explicit, safe code.

Using the Standard Library

Import standard library modules using the import keyword:

import std.random
import std.datetime

func main() returns void {
auto roll = random.next_range(1, 7)
print("You rolled: " + roll.to_string())
}

You can import stdlib in multiple forms:

import std                      // namespace import: std.assert, std.math, std.io, std.random, std.datetime, std.sync, std.net, std.env, std.data, std.dsa, std.sql
import std.math // single module namespace
import std.(math, random as r) // qualified and selective imports with aliasing
import std.* // flat import of all stdlib items

Available Modules

ModuleDescriptionStatus
assertTest assertions that panic on failureAvailable
mathMathematical functions and constantsAvailable
ioFile and path operations with result-based errorsAvailable
netTCP/UDP primitives plus JSON HTTP client/server bindingsAvailable
sqlSQL connections, transactions, result sets, and typed SQL valuesAvailable (SQLite)
envEnvironment inspection utilities (env.get)Available
data.jsonJSON parsing, conversion, and serialization helpersAvailable
data.csvCSV parsing with optional header supportAvailable
randomPseudorandom number generationAvailable
syncThreading, locks, condition variables, and sleep helpersAvailable
datetimeTime retrieval, formatting, and sleep helpersAvailable
dsaData structures and algorithms (stack, queue, heap, bintree, graph)Available

Module Stability

The standard library is published and available. Core modules are stable, and APIs may evolve as new modules are added. Any breaking changes will be documented in release notes.

Future Modules

Planned additions include:

  • string - String manipulation utilities

Contributing

The standard library is part of the Mux language project. Contributions are welcome! See the Contributing Guide for guidelines.