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:- Foundation
- Graphics & GUI
- Web
- Formats & Codecs
- Networking
- Development
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
Strings
Strings
String Types:
String: Modern UTF-8 string (immutable, reference-counted)ByteString: Legacy byte stringStringView: Non-owning string viewFlyString: Interned string for fast comparisonStringBuilder: Efficient string building
Containers
Containers
Collection Types:
Vector<T>: Dynamic array (like std::vector)Array<T, N>: Fixed-size arrayFixedArray<T>: Runtime-sized, non-resizable arrayHashMap<K, V>: Hash tableHashTable<T>: Hash setRedBlackTree<T>: Balanced binary treeIntrusiveList<T>: Intrusive linked list (OOM-safe)CircularQueue<T>: Ring bufferQueue<T>: FIFO queueStack<T>: LIFO stack
Smart Pointers
Smart Pointers
Memory Management:
RefPtr<T>: Reference-counted pointer (nullable)NonnullRefPtr<T>: Non-null reference-counted pointerOwnPtr<T>: Unique ownership pointer (nullable)NonnullOwnPtr<T>: Non-null unique pointerWeakPtr<T>: Weak reference
Utility Types
Utility Types
Helpers:
Optional<T>: Maybe-type (like std::optional)Variant<Ts...>: Type-safe unionErrorOr<T>: Result type for error handlingSpan<T>: Non-owning array viewFunction<R(Args...)>: Function wrapperTime: Time and duration typesChecked<T>: Overflow-checking arithmetic
Streams & I/O
Streams & I/O
Asynchronous I/O:
AsyncStream: Base for async streamsAsyncInputStream: Async inputStream: Synchronous stream baseBufferedStream: Buffered I/OCircularBuffer: Circular buffer
AK Highlights
LibC: C Standard Library
SerenityOS’s custom C library provides POSIX compatibility:- Standard Headers
- System Extensions
- Special Features
stdio.h: Standard I/Ostdlib.h: Memory, program controlstring.h: String operationsunistd.h: POSIX APIpthread.h: Threadingmath.h: Mathematicstime.h: Time functions
LibCore: Core Functionality
LibCore provides essential userspace functionality:Event Loop
See EventLoop Documentation for comprehensive details.
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:HTML Parser & DOM
HTML Parser & DOM
- HTML5 compliant parser
- Full DOM tree implementation
- DOM Level 2 Events
- Shadow DOM support
- Custom elements
CSS Engine
CSS Engine
- CSS3 selector engine
- Flexbox layout
- Grid layout (in progress)
- Animations and transitions
- Media queries
JavaScript Engine (LibJS)
JavaScript Engine (LibJS)
- ES2021+ support
- JIT compilation (in progress)
- Garbage collection
- Module system
- Full standard library
WebAssembly (LibWasm)
WebAssembly (LibWasm)
- WASM bytecode interpreter
- Module loading
- JavaScript integration
- Growing specification support
Web APIs
Web APIs
- Fetch API
- XMLHttpRequest
- Canvas 2D
- WebGL (in progress)
- Web Storage
- Web Workers
LibIPC: Inter-Process Communication
LibIPC provides type-safe IPC between processes:Specialized Libraries
- Multimedia
- Data Formats
- Security
- Games & Apps
- 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
