Standard Library
Asthra Standard Library
Version: 1.2
Status: Complete
Welcome to the Asthra Standard Library documentation! The stdlib provides essential functionality for Asthra programs, including core runtime operations, system interaction, data structures, algorithms, and I/O operations. All modules are designed with AI-first principles, featuring explicit error handling and deterministic behavior.
π Quick Start
// Import convention - always use stdlib/ prefix
import "stdlib/asthra/core";
import "stdlib/string";
import "stdlib/datetime/time";
fn main() -> i32 {
let version = core.runtime_version();
log("INFO", "Running Asthra " + version);
return 0;
}
π Documentation Structure
Core Concepts
Import Convention
How to import and use stdlib modules with proper naming conventions.
Error Handling
Patterns for robust error handling using Result<T, E>
types.
Best Practices
Recommended patterns, techniques, and optimization strategies.
Collections Design
Comprehensive guide to Asthraβs data structures and collection types.
Core Runtime Modules (stdlib/asthra/*
)
Core Module
Runtime internals, memory management, and type system fundamentals.
Panic Handling
Panic handling, debugging utilities, and assertion mechanisms.
Filesystem Operations
File I/O, path utilities, and filesystem interaction.
Environment Access
Environment variables, process information, and system details.
Collections
Vec, HashMap, LinkedList, and other essential data structures.
Mathematics
Mathematical functions, constants, and numerical operations.
Random Generation
Random number generation and cryptographic utilities.
Process Management
Process creation, management, and inter-process communication.
Algorithms
Sorting, searching, and functional programming utilities.
Specialized Modules
Date and Time
Duration handling, timing operations, and system time utilities.
String Processing
String manipulation, UTF-8 support, and text processing.
β¨ Key Features
Memory Safety
- Hybrid GC + Manual Zones: Choose the right memory management for your use case
- Ownership Tracking: Clear ownership semantics for FFI safety
- Zero Memory Leaks: Comprehensive testing ensures no memory leaks
Error Handling
- Explicit Results: All fallible operations return
Result<T, E>
types - Pattern Matching: Systematic error handling with match expressions
- Type Safety: Compile-time error checking prevents runtime failures
AI-Native Design
- Deterministic Behavior: Predictable execution for reproducible results
- Machine-Friendly APIs: Optimized for code generation tools
- Unambiguous Semantics: Clear function signatures and behavior
Cross-Platform Support
- Consistent APIs: Same behavior across Windows, macOS, and Linux
- Platform Detection: Runtime platform identification and adaptation
- Native Performance: Zero-cost abstractions over system calls
π Module Status
Module | Package | Status | Features |
---|---|---|---|
Core | stdlib::asthra::core |
β Complete | Runtime, memory, types |
Panic | stdlib::asthra::panic |
β Complete | Error handling, debugging |
Filesystem | stdlib::asthra::fs |
β Complete | File I/O, paths |
Environment | stdlib::asthra::env |
β Complete | System info, env vars |
Collections | stdlib::asthra::collections |
β Complete | Data structures |
Math | stdlib::asthra::math |
β Complete | Mathematical operations |
Random | stdlib::asthra::random |
β Complete | RNG, cryptography |
Process | stdlib::asthra::process |
β Complete | Process management |
Algorithms | stdlib::asthra::algorithms |
β Complete | Sorting, searching |
Time | stdlib::datetime::time |
β Complete | Duration, timing |
String | stdlib::string |
β Complete | Text processing |
π― Getting Started Guide
For New Users
- Read the Import Convention to understand module usage
- Review Error Handling patterns for robust code
- Explore Collections Design for data structures
- Check Best Practices for recommended patterns
For Advanced Users
- Study Core Modules for runtime internals
- Learn Memory Management techniques
- Explore Performance Optimization strategies
- Review FFI Integration patterns
π‘ Examples
Each module includes comprehensive examples and usage patterns:
- Basic Usage: Simple examples in each moduleβs documentation
- Integration Patterns: Cross-module usage in Best Practices
- Real-World Scenarios: Practical applications and performance guides
- Error Handling: Robust error management patterns
π§ Quality Standards
The Asthra Standard Library maintains strict quality standards:
- β 100% Test Coverage: All functions have comprehensive tests
- β Memory Safety: Zero memory leaks and proper resource management
- β Complete Documentation: Full API documentation with examples
- β High Performance: Competitive performance with equivalent libraries
- β AI-Friendly Design: Optimized for code generation and analysis
The Asthra Standard Library provides the foundation for building robust, high-performance applications with AI-first design principles.