NAAb Pivot is a polyglot code evolution tool that automatically analyzes slow interpreted code (Python, Ruby, JavaScript, NAAb) and generates optimized compiled versions (Go, C++, Rust) while mathematically proving correctness.
- Analyze: Parse source code, detect functions, calculate complexity
- Synthesize: Generate optimized code using templates
- Validate: Run statistical tests to prove parity (99.99% confidence)
- Benchmark: Measure performance improvements
Yes, if parity validation passes. NAAb Pivot includes mathematical proof that legacy and vessel implementations produce identical results. Use conservative or balanced profiles for production.
Typical speedups by workload:
- CPU-bound loops: 3-15x
- Math-heavy: 5-20x
- I/O-bound: 1.5-3x (limited by I/O)
- Cryptographic: 10-25x (with SIMD)
NAAb Pivot automates initial optimization, but manual tuning may achieve higher performance. It's best for:
- Rapid prototyping
- Hotspot optimization
- Incremental migration
- Proof-of-concept
Source (analyzed): Python, Ruby, JavaScript, NAAb, PHP, Java, Go, C#
Target (generated): Go, C++, Rust, Ruby, JavaScript, PHP, Zig, Julia
Yes! Create custom templates in templates/ directory and register in template engine.
99.99% confidence with 100-10,000 test cases. Uses:
- Mean Absolute Error (MAE)
- Kolmogorov-Smirnov test
- Statistical confidence intervals
- Check for floating-point precision issues → increase tolerance
- Look for non-deterministic behavior (random, time-based)
- Verify function has no side effects
- Use
--test-count 10000for more thorough testing
Vessels are cached by SHA-256 hash of:
- Generated source code
- Optimization profile
- Compiler version
- Target architecture
Recompilation only occurs if any of these change.
Common causes:
- I/O-bound workload: File reads/writes limit speedup
- Wrong profile: Try
--profile aggressive - Not CPU-intensive: Simple logic doesn't benefit from compilation
- Overhead: Very short functions (<1ms) may have profiling overhead
Not yet built-in. Use custom plugins for GPU code generation (CUDA, OpenCL).
Yes! Enable with --enable-simd or use aggressive profile. Supports AVX2, AVX-512.
- Go: Automatic goroutines
- Rust: Rayon parallel iterators
- C++: OpenMP pragmas
Enable with --enable-parallel or custom templates.
./naab/build/naab-lang pivot.naab analyze my_module.py --min-complexity 10
./naab/build/naab-lang pivot.naab evolve my_module.pyYes! Use migration planner:
./naab/build/naab-lang migrate.naab create_migration_plan /path/to/projectUse GitHub Action:
- uses: b-macker/naab-pivot@v1
with:
file: slow_code.py
profile: balanced
validate: trueYes! Use Docker:
docker build -t my-vessel .
docker run my-vesselMost common: Missing dependencies. Install:
# Ubuntu/Debian
sudo apt-get install cmake build-essential golang rustc g++
# macOS
brew install cmake go rustEnable parallel compilation:
./naab/build/naab-lang pivot.naab synthesize blueprint.json --parallel 8Check govern.json or use override:
./naab/build/naab-lang pivot.naab --governance-override evolve slow.py| Aspect | NAAb Pivot | Manual Rewriting |
|---|---|---|
| Speed | Minutes | Days/Weeks |
| Correctness | Mathematically proven | Manual testing |
| Flexibility | Template-based | Unlimited |
| Performance | Good (3-15x) | Excellent (10-100x) |
| Maintenance | Automated | Manual |
Use NAAb Pivot for: Rapid optimization, hotspot fixes, POCs
Use Manual Rewriting for: Maximum performance, custom algorithms
JIT compilers optimize at runtime; NAAb Pivot generates ahead-of-time compiled code. NAAb Pivot typically achieves higher speedups for CPU-bound workloads.
Similar goals, different approaches:
- Cython/Numba: Annotate Python code
- NAAb Pivot: Generate new code in different languages
NAAb Pivot is better for complete rewrites; Cython/Numba better for incremental optimization.
MIT License - free for commercial and personal use.
Yes! Generated code is yours to use, modify, and sell.
Yes! See docs/contributing.md for guidelines.
See docs/roadmap.md for planned features:
- More target languages (V, Odin, Nim)
- GPU code generation
- ML-based optimization prediction
- Cloud integration (AWS Lambda, Google Cloud Functions)
- Report bugs: https://github.com/b-macker/naab-pivot/issues
- Write plugins
- Add language templates
- Improve documentation
- Spread the word!
Next: Contributing | Roadmap