Simple like Python, fast with Rust, and everything in between.
An experimental indentation-sensitive programming language with an LLVM backend. OtterLang compiles to native binaries with a focus on simplicity and performance.
Benchmarked against C and Rust using the Leibniz formula for π (100,000,000 iterations):
| C | gcc -O3 | 0.070s | 1.00x (baseline) |
| Rust | rustc -O | 0.080s | 1.14x |
| OtterLang | otter --release | 0.090s | 1.28x |
Each run includes a warm-up execution (not timed). Benchmarks run on macOS with LLVM 15. Run examples/benchmark.sh to test yourself.
Note: These benchmarks are run with a warm-up execution and may not be 100% accurate. Results can vary based on system load, CPU throttling, and other factors.
The setup script will build and install the otter command globally. After installation, you can use otter from anywhere.
OtterLang requires LLVM 15 installed on your system. The compiler uses inkwell which requires LLVM development libraries.
Create a simple program:
Save it as hello.otter and run:
Or build a standalone executable:
OtterLang uses indentation-based syntax (similar to Python) with whitespace-sensitive blocks.
OtterLang provides several built-in modules:
- otter:math - Mathematical functions (sin, cos, sqrt, etc.)
- otter:io - File I/O operations
- otter:fs - File system operations
- otter:http - HTTP client/server
- otter:time - Time utilities (now_ms, sleep, etc.)
- otter:task - Task-based concurrency
- otter:rand - Random number generation
- otter:json - JSON parsing and serialization
- otter:net - Networking (TCP)
- otter:fmt - Formatting utilities
OtterLang supports importing Rust crates through a Foreign Function Interface system. This allows you to use existing Rust libraries in your OtterLang programs.
Import Rust crates using the rust: namespace:
- Bridge Configuration: Each Rust crate requires a bridge.yaml file in ffi/<crate-name>/ that defines how to call Rust functions
- Automatic Compilation: When you use rust:crate, OtterLang automatically:
- Downloads the Rust crate via Cargo (if not already present)
- Generates FFI bindings
- Compiles the bridge library
- Makes functions available to your OtterLang code
- Function Calling: FFI functions are called just like regular OtterLang functions
OtterLang includes bridges for several popular Rust crates:
- serde_json - JSON serialization/deserialization
- rand - Random number generation
- chrono - Date and time handling
- reqwest - HTTP client
- rusqlite - SQLite database driver
- postgres - PostgreSQL database driver
- rayon - Parallel data processing
- nalgebra - Linear algebra library
- libm - Mathematical functions
To add support for a new Rust crate:
- Create ffi/<crate-name>/bridge.yaml
- Define function signatures and call expressions
- See existing bridges in ffi/ for examples
Example bridge.yaml structure:
See docs/DATABASE.md for examples of using database drivers via FFI.
See the examples/ directory for complete examples:
- advanced_pipeline.otter - Complex computation pipeline
- task_benchmark.otter - Task runtime demonstration
- ✅ Indentation-based syntax
- ✅ Type inference and type checking
- ✅ LLVM backend with optimization
- ✅ Standard library modules
- ✅ FFI support for Rust crates
- ✅ Memory management (GC, profiling)
- ✅ Cross-compilation (WASM, embedded)
- ✅ Task-based concurrency
- ✅ REPL
- ✅ Code formatting
- ✅ Memory profiling
⚠️ Early Access Release - OtterLang is experimental and subject to change.
-
Module System: Module imports from .otter files are supported (both relative paths like use ./math and stdlib modules like use otter:math). However, complex module resolution features may have limitations.
-
Type System: Type inference is limited. Explicit type annotations are recommended for complex code, especially for generic types and function signatures.
-
Async/Tasks: The task runtime is functional but some advanced features may be incomplete. Task spawning and channels are supported, but some edge cases may need refinement.
-
Standard Library: Most stdlib modules are implemented, but some may have incomplete implementations or missing edge cases. Check individual module documentation for details.
-
Error Messages: Error reporting is still being improved. Use --dump-tokens and --dump-ast for debugging.
-
Platform Support: Currently tested on macOS and Linux. Windows support is experimental.
-
LLVM Dependency: Requires LLVM 15 specifically. Other versions are not supported.
Contributions are welcome! This is an early-stage project, so expect breaking changes.
MIT License - see LICENSE for details.
Early Access (v0.1.0) - Not production-ready. Use at your own risk.
.png)

