A complete setup guide for the Zixir programming language with all implemented features.
- Prerequisites
- Installation
- Project Setup
- Python Integration
- GPU Computing
- Standard Library
- Building & Testing
- Troubleshooting
| Software | Minimum Version | Recommended |
|---|---|---|
| Erlang/OTP | 25.0+ | 26.x |
| Elixir | 1.14+ | 1.16.x |
| Zig | 0.15+ (or via mix zig.get) |
Zigler downloads 0.15.x automatically |
| Git | 2.0+ | Latest |
| Python | 3.8+ (optional) | 3.11/3.12 for ML/specialist |
| Software | Purpose | Platform |
|---|---|---|
Beaver ({:beaver, "~> 0.4"} in deps) |
MLIR (Phase 4) optimizations | Unix only; not Windows |
| CUDA Toolkit | NVIDIA GPU | Linux/Windows |
| ROCm | AMD GPU | Linux |
| Xcode Command Line Tools | Metal GPU | macOS |
| NumPy | Python array support | All |
See docs/MLIR_AND_PYTHON.md for how to enable optional MLIR.
Windows:
- Option A (Scoop):
scoop install erlang elixir - Option B (installers): Elixir install guide — download the Windows installer, then add the install directory (e.g.
C:\Program Files\Elixir\bin) to PATH.
macOS (via Homebrew):
brew install erlang elixirUbuntu/Debian:
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt-get update
sudo apt-get install erlang elixirZigler will download Zig 0.15.x when you run mix zig.get. If you prefer a system Zig (e.g. for other tools), use 0.15+:
Windows:
scoop install zig
# Or: download from https://ziglang.org/download/macOS:
brew install zigLinux:
# Example: Zig 0.15.x
wget https://ziglang.org/download/0.15.2/zig-linux-x86_64-0.15.2.tar.xz
tar -xf zig-linux-x86_64-0.15.2.tar.xz
sudo mv zig-linux-x86_64-0.15.2 /opt/zig
export PATH=/opt/zig:$PATHWindows:
scoop install python
pip install numpymacOS:
brew install python numpyUbuntu/Debian:
sudo apt-get install python3-dev python3-pip python3-numpyEnsure Git is installed and available in PATH.
One-shot installer (Quick start + optional GPU): Runs git clone, cd Zixir, git checkout v5.3.0, mix deps.get, mix zig.get, mix compile, then optionally installs platform GPU deps: Metal (macOS), CUDA (Windows/Linux NVIDIA), ROCm (Linux AMD).
- Unix/macOS:
./scripts/install-zixir.sh [install-dir]— e.g../scripts/install-zixir.sh(current dir) or./scripts/install-zixir.sh /opt - Windows:
.\scripts\install-zixir.ps1 [install-dir]— e.g..\scripts\install-zixir.ps1or.\scripts\install-zixir.ps1 C:\dev(includes CUDA script)
Manual steps:
# Clone the repository
git clone https://github.com/Zixir-lang/Zixir.git
# IMPORTANT: Navigate into the project directory
cd Zixir
# Install Elixir dependencies
mix deps.get
# Fetch Zig for Zigler (required for NIF compilation)
mix zig.get
# Compile the project
mix compile
# Run a simple example to verify installation
mix zixir.run examples/hello.zixirWindows: You can also run .\scripts\verify.ps1 from the repo root to run deps.get, zig.get, compile, and the hello example in one go.
Optional (GPU): To install platform-specific GPU dependencies (CUDA / ROCm / Metal) for ML or GPU offload, run from the repo root:
- Quick check (prints instructions):
./scripts/install-gpu-deps.sh(Unix/macOS) or.\scripts\install-gpu-deps.ps1(Windows). - Full install (runs install steps):
./scripts/install-optional-deps.sh(Unix/macOS: Metal or Linux CUDA/ROCm) or.\scripts\install-optional-deps.ps1 [-Install] [-OpenDownload](Windows: CUDA). See GPU Computing below for manual setup.
Add to your mix.exs:
def deps do
[
{:zixir, "~> 1.0"}
]
endFor tools and integrations, you can install Zixir so it runs from any terminal path:
-
Build the release (from the Zixir repo root):
mix release
By default this creates a dev release. For a production release:
MIX_ENV=prod mix release. -
Add the release
bin/to your PATH:- Unix/macOS:
_build/dev/rel/zixir/bin/(default) or_build/prod/rel/zixir/bin/(afterMIX_ENV=prod mix release). - Windows: Same folder; use
zixir_run.batfor the portable runner.
- Unix/macOS:
-
Run a
.zixirfile from any directory:- Unix/macOS:
zixir_run.sh /path/to/script.zixir - Windows:
zixir_run.bat C:\path\to\script.zixir
Paths can be absolute or relative to the current working directory. The scripts call
Zixir.CLI.run_file_from_argv()and pass the path after--. - Unix/macOS:
-
Alternative (any OS): Use the release
evalcommand with argv (same as the scripts):bin/zixir eval "Zixir.CLI.run_file_from_argv()" -- /path/to/file.zixir
Once bin/ is on PATH, you can run Zixir scripts from any folder (CI, scripts, other tools) without cd-ing into the Zixir project.
# Initialize Python
Zixir.Python.init()
# => {:ok, "3.11"} or {:error, :not_available}
# Call Python functions
Zixir.Python.call("math", "sqrt", [16.0])
# => {:ok, 4.0}
# Check module availability
Zixir.Python.has_module?("numpy")
# => true
# Create NumPy arrays (fast with NIF)
{:ok, arr} = Zixir.Python.numpy_array([1.0, 2.0, 3.0])
# Execute Python code
Zixir.Python.exec("result = sum(range(10))")
# => {:ok, "45"}
# Cleanup
Zixir.Python.finalize()In config/config.exs:
config :zixir,
python_mode: :auto # :nif, :port, or :auto:nif- Force direct C API (fastest when NIF is built):port- Use port-based (works without NIF):auto- Auto-detect (default)
| Mode | Speed | Requirements |
|---|---|---|
| NIF (default) | 100-1000x faster | Python dev headers, Zig |
| Port | Standard | Python only |
| Backend | Platform | Requirements |
|---|---|---|
| CUDA | Linux/Windows | NVIDIA GPU, CUDA Toolkit |
| ROCm | Linux | AMD GPU, ROCm |
| Metal | macOS | Apple Silicon or Intel Mac |
# Check available backends
Zixir.Compiler.GPU.available?()
# => true
# Compile for specific backend (returns kernel path and backend)
{:ok, kernel_path, backend} = Zixir.Compiler.GPU.compile(ast, backend: :cuda)
# backend is :cuda, :rocm, or :metal
# Execute with automatic data transfer (returns {:ok, result_data})
{:ok, result} = Zixir.Compiler.GPU.execute_kernel(kernel_path, data, backend: :cuda)
# Allocate GPU buffer
{:ok, buffer} = Zixir.Compiler.GPU.allocate_buffer(size, backend: :cuda)
# Get device info
Zixir.Compiler.GPU.device_info(0)
# => {:ok, %{name: "NVIDIA GeForce RTX 3080", ...}}# Install CUDA Toolkit (Ubuntu)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1-all.deb
sudo dpkg -i cuda-keyring_1.1-1-all.deb
sudo apt-get update
sudo apt-get install cuda-toolkit-12-0Prerequisites:
- NVIDIA GPU with compute capability 5.0+
- Windows 10/11 64-bit
Installation:
-
Download CUDA Toolkit:
- Visit: https://developer.nvidia.com/cuda-downloads
- Select: Windows → x86_64 → 10/11 → exe (local)
- Download CUDA Toolkit 12.x (or latest)
-
Run Installer:
- Double-click the downloaded
.exe - Choose "Express Installation" (recommended)
- Or "Custom Installation" to select specific components
- Ensure "CUDA" → "Development" → "Compiler" is selected (for
nvcc)
- Double-click the downloaded
-
Verify PATH:
The installer should add CUDA to your PATH automatically. Verify:
nvcc --versionIf not found, manually add to PATH:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\binC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\libnvvp
-
Verify GPU Detection:
nvidia-smi
Quick install via package managers:
- Chocolatey:
choco install cuda - Winget:
winget install Nvidia.CUDA
Post-installation: Restart your terminal or IDE to pick up the new PATH variables.
Note: Zixir's GPU detection (gpu.ex) uses nvcc --version to detect CUDA. This works on Windows as long as nvcc is in your system PATH.
# Install ROCm (Ubuntu)
wget https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/rocm.gpg.key
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/5.4.3 ubuntu22.04 main' | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
sudo apt install rocm-dev# Install Xcode Command Line Tools
xcode-select --installZixir.Modules.call("std/math", :sin, [0.5]) # => {:ok, 0.4794}
Zixir.Modules.call("std/math", :cos, [0.5]) # => {:ok, 0.8776}
Zixir.Modules.call("std/math", :sqrt, [16]) # => {:ok, 4.0}
Zixir.Modules.call("std/math", :log, [2.71828]) # => {:ok, 1.0}
Zixir.Modules.call("std/math", :pi, []) # => {:ok, 3.14159}Zixir.Modules.call("std/list", :map, [[1, 2, 3], fn x -> x * 2 end])
# => {:ok, [2, 4, 6]}
Zixir.Modules.call("std/list", :filter, [[1, 2, 3, 4], fn x -> x > 2 end])
# => {:ok, [3, 4]}
Zixir.Modules.call("std/list", :reduce, [[1, 2, 3, 4], 0, fn a, b -> a + b end])
# => {:ok, 10}
Zixir.Modules.call("std/list", :sort, [[3, 1, 4, 1, 5, 9, 2, 6]])
# => {:ok, [1, 1, 2, 3, 4, 5, 6, 9]}Zixir.Modules.call("std/string", :length, ["hello"])
# => {:ok, 5}
Zixir.Modules.call("std/string", :split, ["hello world", " "])
# => {:ok, ["hello", "world"]}
Zixir.Modules.call("std/string", :upper, ["hello"])
# => {:ok, "HELLO"}Zixir.Modules.call("std/io", :print, ["Hello, World!"])
Zixir.Modules.call("std/io", :println, ["Line with newline"])
Zixir.Modules.call("std/io", :read_line, [])Zixir.Modules.call("std/json", :encode, [%{name: "John", age: 30}])
# => {:ok, "{\"name\":\"John\",\"age\":30}"}
Zixir.Modules.call("std/json", :decode, ["{\"name\":\"John\"}"])
# => {:ok, %{name: "John"}}Zixir.Modules.call("std/random", :uniform, [1, 100])
# => {:ok, random integer between 1-100}
Zixir.Modules.call("std/random", :shuffle, [[1, 2, 3, 4, 5]])
# => {:ok, shuffled list}Zixir.Modules.call("std/stat", :mean, [[1, 2, 3, 4, 5]])
# => {:ok, 3.0}
Zixir.Modules.call("std/stat", :median, [[1, 2, 3, 4, 5]])
# => {:ok, 3.0}
Zixir.Modules.call("std/stat", :std_dev, [[1, 2, 3, 4, 5]])
# => {:ok, 1.4142}Zixir.Modules.call("std/time", :now, [])
# => {:ok, 1706745600000}
Zixir.Modules.call("std/time", :sleep, [1000])
# Sleeps for 1 second# Compile with all warnings
mix compile
# Clean and recompile
mix clean && mix compile
# Build release
mix release
# Build documentation
mix docs# Run all tests
mix test
# Run specific test file
mix test test/zixir/compiler/parser_test.exs
# Run tests with coverage
mix coveralls
# Run tests in parallel
mix test --cover# Run benchmarks
mix bench{:error, :not_available}
Solution: Ensure Python is installed and in PATH:
python3 --version{:error, :numpy_not_available}
Solution: Install NumPy:
pip install numpy{:error, :cuda_not_available}
Solution:
- Verify NVIDIA GPU:
nvidia-smi - Install CUDA Toolkit
- Ensure
nvccis in PATH
{:error, :metal_not_available}
Solution: Install Xcode Command Line Tools:
xcode-select --install** (Mix) The task "phx.server" could not be found
Solution: You are not in the Zixir project directory. Make sure to:
cd Zixir # Navigate to the project folder
mix phx.serverVerify you're in the right place:
pwd # Should show .../Zixir
ls mix.exs # Should list the mix.exs filecould not find zig executable
Solution:
- Verify Zig installation:
zig version - Add Zig to PATH
- Clean build:
mix deps.clean --build zigler && mix compile
- GitHub Issues: Report bugs and feature requests
- Documentation: See
docs/directory - REPL: Use
iex -S mixfor interactive testing
Zixir/
├── lib/ # Elixir source
│ ├── zixir/ # Main application
│ ├── compiler/ # Compiler components
│ └── mix/ # Mix tasks
├── priv/ # Native code
│ ├── python/ # Port bridge (port_bridge.py)
│ ├── python_nif.zig # Python NIF (Zig)
│ └── zig/ # Zig runtime
├── rel/overlays/bin/ # Release scripts (zixir_run.sh, zixir_run.bat)
├── test/ # Test files
├── docs/ # Documentation
├── mix.exs # Mix project file
└── README.md # Project README
- Read the README for language basics
- Try the REPL:
iex -S mix - Build a sample project using the standard library
- Explore GPU computing with CUDA/Metal
- Integrate Python libraries for data science
Happy Coding with Zixir!