Standard Library

Every language needs a standard library, and I've built one for Adama. These are the built-in functions and methods that come with the language out of the box -- string manipulation, math, dates, collections, statistics, and a few things I needed that didn't fit neatly anywhere else.

Design Philosophy

I went with a method-centric design for the stdlib. Instead of calling static functions like Math.abs(x), you call methods directly on values:

int x = -42;
int absX = x.abs();  // Method style

It reads better. It chains better. That's about it.

Chapters

1. Strings

String manipulation -- splitting, searching, trimming, case conversion, substring extraction. The usual suspects, plus String.charOf() for when you need to go from codepoint to character.

2. Math

Math operations on int, long, double, and complex types. Absolute value, rounding, square roots, trig. Nothing surprising, but it's all there.

3. Date and Time

Date and time handling with four temporal types: date, time, datetime, and timespan. Construction, arithmetic, formatting, calendar views. Dates are annoyingly hard to get right; I've tried to make them less annoying here.

4. Collections

Operations on lists, maps, and arrays. size(), reverse(), skip(), drop(), map operations, iteration patterns. The bread and butter of working with data.

5. Statistics

Statistical aggregation -- sum, count, average -- for working with collections of numeric data. Pairs naturally with the query system.

6. Global Objects

Built-in global objects: Document for lifecycle stuff, Time for timezone management, Random for randomness, Messaging for programmatic message delivery, ViewState for poking at client state, and Principal for identity operations.

7. Dynamic

Working with dynamic (JSON-like) data: creating, parsing, inspecting, and transforming schema-free values. Also covers the Json global for structured navigation. This is your escape hatch when you need to deal with untyped data.

8. Utilities

The junk drawer. HTML processing, token manipulation, template rendering, and procedural maze generation. These are things I needed at various points and figured other people might too.

9. Vectors and Matrices

Linear algebra -- 2D, 3D, and 4D vectors and matrices. Arithmetic, rotation, transformation, inverse computation. If you're building a game or doing spatial work, this is where you look.

Working with Maybe Types

A lot of standard library functions accept and return maybe<T> types. This is how Adama handles cases where an operation might not produce a valid result -- you get null safety baked into the API rather than runtime exceptions:

procedure foo() {
  string text = "hello world";
  maybe<string> sub = text.mid(0, 5);  // Returns maybe<string>

  if (sub as value) {
    // Use value safely here
  }
}

Getting Started

If you're looking for something specific:

Previous Debug
Next Strings