Guide Index Previous Part Next Part Download Markdown

#Part 5. Libraries

#Part 5 Section 1. Learn These First

Most first apps need only a small library set.

LibraryPurpose
CB-ConsoleInput and terminal output
CB-MathChecked numeric helpers and fallbacks
CB-Storage.cb saves
CB-AssetLoaderProject assets
CB-UIHTML UI
CB-RenderDirect drawing
CB-PopupUser-facing error dialogs
CB-Networking.HTTPOutgoing web requests
CB-Networking.APILocal routes or API clients
CB-Security.AuthLogin/session checks
CB-Security.RBACRole checks
CB-Library.TestingAssertions and small benchmarks
CB-Library.LoggingDebug logs

Import the libraries you use. A short import list makes missing functions easier to spot.

#Part 5 Section 2. Making A Library

A .cbl library should do one job clearly. Export stable functions and build it with compile library.

library CB-TextTools

fn CB-TextTools.slug(string text) -> string {
    string lower = string.lower(text)
    return string.replace(lower, " ", "-")
}
compile library CB-TextTools.cbp bin/CB-TextTools.cbl small compute

Place the compiled .cbl in the project libraries folder, then import it from another .cbp.