Lux is designed to be language-agnostic, allowing you to build agents in your preferred programming language. This guide provides an overview of language support in Lux and how to use different programming languages in your agents.
Learn more about Python integration
Python is a first-class citizen in Lux, with deep integration into the framework. You can:
- Write Python code directly in your Elixir files using
~PY
sigils - Add custom Python modules under
priv/python
and import them - Use any Python package through pip/poetry
- Leverage Python's rich ML and data science ecosystem
🔥 Coming Soon: Define Prisms, Beams, and other Lux components entirely in Python! This will allow you to write your agents' logic completely in Python while still leveraging Lux's powerful orchestration capabilities.
Learn more about Node.js integration
Node.js integration allows you to leverage the vast JavaScript ecosystem:
- Write JavaScript/TypeScript code using
~JS
sigils - Use NPM packages in your agents
- Support for modern ES modules and async/await
- Full access to Node.js APIs
Native Rust integration is under development, which will provide:
- High-performance components for compute-intensive tasks
- Direct FFI integration for optimal performance
- Access to Rust's rich ecosystem
- Memory-safe interop with Elixir
Want to add support for your favorite language? Lux provides a Language Integration Protocol that allows you to:
- Add new language runtimes
- Define type conversion rules
- Handle package management
- Implement error handling
Check out our Contributing Guide for details on adding language support.
-
Choose the Right Language
- Use Python for ML/AI tasks and data processing
- Use Node.js for web integration and text processing
- Use Elixir for coordination and state management
- Consider Rust (coming soon) for performance-critical components
-
Package Management
- Add custom Python modules under
priv/python/
- Use
poetry
for Python dependency management - Use
npm
/yarn
for Node.js dependencies - Follow the language's best practices for versioning
- Add custom Python modules under
-
Performance Considerations
- Minimize cross-language calls
- Batch operations when possible
- Use appropriate data serialization
- Consider memory usage patterns
-
Security
- Validate all inputs
- Control package versions
- Follow security best practices for each language
- Implement proper sandboxing
Check out these examples of language integration:
- Trading System: Uses Python for data analysis
- Content Creation: Uses JavaScript for text processing
- Research Assistant: Combines multiple languages
Want to add support for a new language? Check our Contributing Guide and:
- Review the Language Integration Protocol
- Create a proof of concept
- Add comprehensive tests
- Document the integration
- Submit a pull request
For detailed examples and up-to-date documentation, visit hexdocs.pm/lux.