ALaS is a general-purpose, Turing-complete programming language designed exclusively for AI models to generate, manipulate, and execute. It uses structured JSON representations to enable low-error, high-speed code generation and transformation by LLMs.
For LLM Users: Check out our comprehensive documentation designed specifically to help AI systems generate ALaS code effectively. The LLM Integration Guide provides optimal prompting strategies and common patterns.
- Machine-First Design: Optimized for AI generation, not human readability
- JSON-Based: All code is represented as structured JSON following a strict schema with comprehensive validation
- Turing-Complete: Supports functions, conditionals, loops, and recursion
- Type System: Basic types including int, float, string, bool, array, and map with custom struct and enum support
- Enhanced Validation: Comprehensive JSON schema validation for all language constructs with detailed error reporting
- Module System: Import/export capabilities with dependency resolution and encapsulation
- Standard Library: Comprehensive runtime implementation for I/O, math, collections, strings, and more
- Plugin System: Dynamic extensibility with security, sandboxing, and multiple plugin types
alas/
├── cmd/
│ ├── alas-validate/ # AST validation tool
│ ├── alas-run/ # Reference interpreter
│ ├── alas-compile/ # Single-module LLVM IR compiler
│ ├── alas-compile-multi/ # Multi-module LLVM IR compiler with linking
│ ├── alas-plugin/ # Plugin management tool
│ └── alas-stdlib/ # Standard library shared object builder
├── internal/
│ ├── ast/ # AST type definitions
│ ├── validator/ # AST validation logic
│ ├── interpreter/ # Reference interpreter
│ ├── codegen/ # LLVM IR code generator, optimizer, and multi-module system
│ ├── plugin/ # Plugin system implementation
│ ├── runtime/ # Runtime value types
│ └── stdlib/ # Standard library runtime implementation
├── stdlib/ # Standard library modules
├── examples/
│ ├── programs/ # Example ALaS programs
│ ├── modules/ # Example ALaS modules (math_utils, format_utils)
│ └── plugins/ # Example plugin implementations
├── tests/ # Test suite with optimization and multi-module tests
└── docs/ # Comprehensive documentation
├── README.md # Documentation overview
├── language-spec.md # Complete language specification
├── getting-started.md # Quick start guide
├── stdlib-reference.md # Standard library reference
├── plugin-system.md # Plugin development guide
├── examples.md # Code examples and patterns
├── llm-guide.md # LLM integration guide
└── troubleshooting.md # Common issues and solutions
- Getting Started Guide - Quick introduction to writing ALaS programs
- Language Specification - Complete language reference
- Standard Library Reference - All built-in functions
- Plugin System Guide - Extending ALaS
- Examples - Sample programs and patterns
- LLM Integration Guide - For AI-assisted development
- Troubleshooting - Common issues and solutions
- Go 1.24.4 or later - The ALaS compiler is written in Go
- LLVM 14 or later - Required for LLVM IR compilation and optimization
Go Installation:
- Download from golang.org
- Verify:
go versionshould show 1.24.4 or later
LLVM Installation:
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y llvm-14 llvm-14-dev clang
sudo ln -sf /usr/bin/llvm-config-14 /usr/bin/llvm-configmacOS:
brew install llvm
# Add LLVM to PATH if needed
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"Windows:
- Download LLVM from releases.llvm.org
- Add LLVM bin directory to PATH
Verify Installation:
llvm-config --version # Should show LLVM version
clang --version # Should show Clang version- golangci-lint - For running code quality checks
- git - For version control and CI/CD
make buildThis creates six binaries in the bin/ directory:
alas-validate- Validates ALaS JSON programsalas-run- Executes ALaS programsalas-compile- Compiles single ALaS programs to LLVM IRalas-compile-multi- Compiles multi-module ALaS programs with cross-module linkingalas-plugin- Manages plugins (list, install, create, etc.)alas-stdlib- Builds standard library as shared object
# Run all examples
make run-all-examples
# Run a specific example
./bin/alas-run -file examples/programs/hello.alas.json
# Run array example
./bin/alas-run -file examples/programs/simple_array.alas.json
# Run module example
./bin/alas-run -file examples/programs/module_demo.alas.json
# Run a specific function with arguments (default function is 'main')
./bin/alas-run -file examples/programs/fibonacci.alas.json -fn mainALaS includes comprehensive JSON schema validation for all language constructs:
# Validate a single program
./bin/alas-validate -file examples/programs/hello.alas.json
# Validation includes:
# - Module structure and naming
# - Function definitions and parameters
# - Statement and expression syntax
# - Type definitions and usage
# - Import/export validation
# - Builtin function namespace checking
# - Custom type validation (structs/enums)# Single-module compilation
./bin/alas-compile -file examples/programs/factorial.alas.json
# Multi-module compilation with cross-module linking
./bin/alas-compile-multi -file examples/programs/module_demo.alas.json -module-path examples
# Compile with optimizations
./bin/alas-compile -file examples/programs/factorial.alas.json -O 2
# Multi-module linking modes
./bin/alas-compile-multi -file examples/programs/module_demo.alas.json -module-path examples -link all -o linked_program.ll
# Available optimization levels:
# -O 0 No optimizations (default)
# -O 1 Basic optimizations (constant folding, dead code elimination)
# -O 2 Standard optimizations (includes mem2reg, common subexpression elimination)
# -O 3 Aggressive optimizations (includes function inlining, loop optimizations)
# Compile all examples
make compile-examples
# Plugin management
make plugin-list
make validate-pluginsmake testALaS programs are written in structured JSON format. Here's a simple "Hello, World!" example:
{
"type": "module",
"name": "hello",
"functions": [
{
"name": "main",
"params": [],
"returns": "string",
"body": [
{
"type": "return",
"value": {
"type": "literal",
"value": "Hello, ALaS!"
}
}
]
}
]
}See Examples Documentation for more comprehensive examples including arrays, maps, functions, modules, and advanced patterns.
ALaS includes a comprehensive standard library with native runtime implementations for all core functionality including I/O, math, collections, strings, type checking, error handling, and async programming.
See the Standard Library Reference for complete documentation of all modules and functions.
ALaS features a comprehensive plugin system that enables dynamic extension of the language while maintaining security and type safety. The system supports multiple plugin types including module, native, hybrid, and built-in plugins with sandboxing and capability-based security.
See the Plugin System Guide for complete documentation on plugin development, management, and security features.
ALaS compiles to LLVM IR with multi-level optimization support (O0-O3) providing significant performance improvements. The system supports both single-module and cross-module compilation with dependency resolution and linking.
ALaS is a Turing-complete language with functions, conditionals, loops, recursion, arrays, maps, and a module system with import/export capabilities.
See the Language Specification for complete details on all language constructs, types, and syntax.
Current implementation includes:
- ✅ AST definition and validation
- ✅ Reference interpreter
- ✅ LLVM IR code generation with multi-level optimization
- ✅ Basic type system
- ✅ Functions and recursion
- ✅ Control flow (if/else, while loops)
- ✅ Binary and unary operations
- ✅ Arrays and maps with indexing
- ✅ Module imports/exports with dependency resolution
- ✅ Standard library runtime implementation (7 core modules)
- ✅ Plugin system with security and multi-type support
- ✅ Comprehensive test suite with optimization testing
- ✅ Runtime garbage collection for arrays/maps (reference counting)
- ✅ LLVM backend support for builtin expressions (standard library in compiled code)
Recent additions:
-
✅ LLVM IR Optimization System - Complete multi-level optimization framework
- O0: No optimizations (baseline)
- O1: Basic optimizations (constant folding, dead code elimination, mem2reg)
- O2: Standard optimizations (adds common subexpression elimination, CFG simplification)
- O3: Aggressive optimizations (adds function inlining, loop invariant code motion)
-
✅ Optimization Test Suite - Unit tests, benchmarks, and integration tests
-
✅ Performance Improvements - 16-63% code size reduction with optimizations
-
✅ Cross-module LLVM Compilation and Linking - Complete multi-module compilation system
- Dependency Resolution: Topological sorting with circular dependency detection
- External Function Declarations: Proper LLVM IR with qualified function names
- Module Loaders: Flexible module discovery and loading system
- Linking Modes: Both separate compilation and whole-program linking
- Multi-Module CLI: New
alas-compile-multitool with comprehensive options
-
✅ Standard Library Runtime Implementation - Native Go implementations for all core modules
- std.io: File operations and console I/O with Result types
- std.math: Mathematical functions with cryptographically secure random
- std.collections: Array and map utilities with slice operations
- std.string: String manipulation with split/join/replace
- std.type: Type checking and conversion utilities
- std.result: Structured error handling pattern
- std.async: Concurrent/async programming with tasks, parallel, race, and cancellation
-
✅ Runtime Garbage Collection - Reference counting GC for arrays and maps
- Reference Counting: Automatic memory management with retain/release
- Nested Object Support: Proper cleanup of nested arrays/maps
- Automatic Cleanup: Variables release old values on reassignment
- Function Cleanup: Local GC objects released on function return
- GC Threshold: Automatic collection when object count exceeds limit
-
✅ LLVM Builtin Support - Standard library functions in compiled code
- I/O Functions: io.print
- Math Functions: math.sqrt, math.abs
- Collection Functions: collections.length
- String Functions: string.toUpper
- Type Functions: type.typeOf
-
✅ Enhanced LLVM Codegen and Error Handling - Comprehensive language feature completion
- Dynamic Field Access: Fixed field access compilation for dynamically-typed objects
- Complete Array Operations: Array element assignment, length, slicing with bounds checking
- Complete Map Operations: Map operations (get, put, contains, remove, keys, values)
- String Functions: All string manipulation functions (substring, indexOf, split, join, replace, etc.)
- Enhanced Module System: Module caching, dependency resolution, type imports
- Runtime Error Handling: Division by zero checks, bounds checking, null pointer checks, assertions
-
✅ std.async Module Implementation - Full async/concurrent programming support
- Task System: Spawn async tasks with context-based cancellation
- Synchronization: await, awaitTimeout for task completion
- Concurrency Patterns: parallel (wait for all), race (first to complete)
- Utilities: sleep, timeout, cancel, isRunning, isCompleted
- Error Handling: Result-based error propagation for async operations
Future work (Priority order):
- ⏳ Plugin marketplace and hot reloading - Dynamic plugin management
- Hot reload capability for development
- Remote plugin repository and marketplace
- Automated plugin installation/updates
- ⏳ Additional optimization passes - Advanced compiler optimizations
- Vectorization/auto-vectorization for SIMD operations
- Dead store elimination (DSE)
- Loop unrolling
- Global value numbering
- Instruction combining
This project is licensed under the MIT License - see the LICENSE file for details.