Skip to main content
SerenityOS includes approximately 80 libraries in Userland/Libraries/, all built from scratch. These libraries range from fundamental data structures (AK) to a complete web browser engine (LibWeb).

Library Organization

Libraries are categorized by functionality:
Core Infrastructure:
  • AK: Application Kit - fundamental data structures
  • LibC: C standard library (POSIX-compatible)
  • LibMain: Modern main() entry point
  • LibCore: Core functionality (event loop, I/O, system)
  • LibThreading: Threading primitives

AK: Application Kit

AK is the foundation library providing fundamental data structures and utilities:
Located in the /AK directory at the repository root, AK is usable in both kernel and userspace.

Core Data Structures

String Types:
  • String: Modern UTF-8 string (immutable, reference-counted)
  • ByteString: Legacy byte string
  • StringView: Non-owning string view
  • FlyString: Interned string for fast comparison
  • StringBuilder: Efficient string building
Collection Types:
  • Vector<T>: Dynamic array (like std::vector)
  • Array<T, N>: Fixed-size array
  • FixedArray<T>: Runtime-sized, non-resizable array
  • HashMap<K, V>: Hash table
  • HashTable<T>: Hash set
  • RedBlackTree<T>: Balanced binary tree
  • IntrusiveList<T>: Intrusive linked list (OOM-safe)
  • CircularQueue<T>: Ring buffer
  • Queue<T>: FIFO queue
  • Stack<T>: LIFO stack
Memory Management:
  • RefPtr<T>: Reference-counted pointer (nullable)
  • NonnullRefPtr<T>: Non-null reference-counted pointer
  • OwnPtr<T>: Unique ownership pointer (nullable)
  • NonnullOwnPtr<T>: Non-null unique pointer
  • WeakPtr<T>: Weak reference
Helpers:
  • Optional<T>: Maybe-type (like std::optional)
  • Variant<Ts...>: Type-safe union
  • ErrorOr<T>: Result type for error handling
  • Span<T>: Non-owning array view
  • Function<R(Args...)>: Function wrapper
  • Time: Time and duration types
  • Checked<T>: Overflow-checking arithmetic
Asynchronous I/O:
  • AsyncStream: Base for async streams
  • AsyncInputStream: Async input
  • Stream: Synchronous stream base
  • BufferedStream: Buffered I/O
  • CircularBuffer: Circular buffer
See Asynchronous Design Documentation for details.

AK Highlights

LibC: C Standard Library

SerenityOS’s custom C library provides POSIX compatibility:
  • stdio.h: Standard I/O
  • stdlib.h: Memory, program control
  • string.h: String operations
  • unistd.h: POSIX API
  • pthread.h: Threading
  • math.h: Mathematics
  • time.h: Time functions

LibCore: Core Functionality

LibCore provides essential userspace functionality:

Event Loop

See EventLoop Documentation for comprehensive details.
The event loop is central to GUI and network applications:

File I/O

Process Management

LibGUI: GUI Framework

LibGUI provides the graphical user interface framework:

Widgets

  • Button, Label, TextBox, TextEditor
  • ListView, TableView, TreeView
  • ScrollBar, Slider, ProgressBar
  • MenuBar, Menu, MenuItem
  • Window, Dialog, MessageBox
  • Layout managers (Horizontal, Vertical, etc.)

Models

  • Model-View architecture
  • AbstractTableModel
  • SortingProxyModel
  • FileSystemModel
  • Custom model support

Example GUI Application

LibWeb: Web Engine

LibWeb is a complete browser engine built from scratch:
  • HTML5 compliant parser
  • Full DOM tree implementation
  • DOM Level 2 Events
  • Shadow DOM support
  • Custom elements
  • CSS3 selector engine
  • Flexbox layout
  • Grid layout (in progress)
  • Animations and transitions
  • Media queries
  • ES2021+ support
  • JIT compilation (in progress)
  • Garbage collection
  • Module system
  • Full standard library
  • WASM bytecode interpreter
  • Module loading
  • JavaScript integration
  • Growing specification support
  • Fetch API
  • XMLHttpRequest
  • Canvas 2D
  • WebGL (in progress)
  • Web Storage
  • Web Workers
Check compliance:

LibIPC: Inter-Process Communication

LibIPC provides type-safe IPC between processes:
See IPC Architecture for details.

Specialized Libraries

  • LibAudio: Audio codecs and playback
  • LibVideo: Video decoding
  • LibDSP: Digital signal processing
  • LibSynthesizer: Audio synthesis

Library Design Patterns

Cross-Library Dependencies

Libraries have clear dependency relationships:

Further Reading

IPC Details

Learn about inter-process communication

Event Loop

Understand the event system

Smart Pointers

Memory management patterns

Coding Patterns

Common patterns and idioms