Rustler: Bridging Elixir and Rust with Sonny Scroggin
Rustler Core Team Member Sonny Scroggin joins Elixir Wizards Sundi Myint and Charles Suggs. Rustler serves as a bridge to write Native Implemented Functions (NIFs) in Rust that can be called from Elixir code. This combo leverages Rust's performance and memory safety while maintaining Elixir's fault tolerance and concurrency model, creating a powerful solution for CPU-intensive operations within Elixir applications.
Sonny provides guidance on when developers should consider using NIFs versus other approaches like ports or external services and highlights the considerations needed when stepping outside Elixir's standard execution model into native code.
Looking toward the future, Sonny discusses exciting developments for Rustler, including an improved asynchronous NIF interface, API modernization efforts, and better tooling. While Rust offers tremendous performance benefits for specific use cases, Sonny emphasizes that Elixir's dynamic nature and the BEAM's capabilities for distributed systems remain unmatched for many applications. Rustler simply provides another powerful tool that expands what developers can accomplish within the Elixir ecosystem.
Key topics discussed in this episode:
Rust as a "high-level low-level language" with memory safety
NIFs (Native Implemented Functions) in the BEAM virtual machine
Rustler's role simplifying Rust-Elixir integration with macros
CPU-intensive operations as primary NIF use cases
Beam scheduler interaction considerations with native code
Dirty schedulers for longer-running NIFs in OTP 20+
Memory safety advantages of Rust for NIFs
Development workflow using Mix tasks for Rustler
Common pitfalls when first working with Rust
Error handling improvements possible with Rustler NIFs
Differences between ports, NIFs, and external services
Asynchronous programming approaches in Rust versus Elixir
Tokyo runtime integration for asynchronous operations
Static NIFs for mobile device compatibility
Upcoming CLI tooling to simplify Rustler development
Rustler's API modernization efforts for better ergonomics
Thread pool sharing across multiple NIFs
Wasm integration possibilities for the BEAM
Compile-time safety versus dynamic runtime capabilities
Performance considerations when implementing NIFs
Compiler-assisted memory management in Rust
Automatic encoding/decoding between Rust and Elixir types
The importance of proper error handling
Real-world application in high-traffic authentication servers
Community resources for learning Rustler
Links mentioned:
https://github.com/rusterlium/rustler
https://github.com/rust-lang/rust
https://www.angelfire.lycos.com/
https://www.webdesignmuseum.org/flash-websites
https://www.php.net/
https://xmpp.org/
https://jabberd2.org/
Geocities: https://cybercultural.com/p/geocities-1995/ (fun fact: when you search Geocities on Google, the results page is in Comic Sans font.)
https://bleacherreport.com/
https://hexdocs.pm/jose/readme.html
https://github.com/rust-lang/rust-bindgen
Erlang Ports: https://www.erlang.org/doc/system/cport.html
Erlang ETFs (External Term Format): https://www.erlang.org/doc/apps/erts/erlextdist.html
Elixir gRPC https://github.com/elixir-grpc/grpc
gRPC (“Remote Proceduce Call”): https://grpc.io/
dirtycpu.ex https://github.com/E-xyza/zigler/blob/main/lib/zig/nif/dirty_cpu.ex
ets https://www.erlang.org/doc/apps/stdlib/ets.html
Mnesia https://www.erlang.org/doc/apps/mnesia/mnesia.html
VPPs (Virtual Power Plants): https://www.energy.gov/lpo/virtual-power-plants
https://nixos.org/
WASM WebAssembly with Elixir: https://github.com/RoyalIcing/Orb
Rust Tokio https://tokio.rs/
Getting Started:
https://hexdocs.pm/rustler/0.17.0/Mix.Tasks.Rustler.New.html
https://rustup.rs/
Special Guest: Sonny Scroggin.
--------
48:58
Nx and Machine Learning in Elixir with Sean Moriarity
Today on Elixir Wizards, hosts Sundi Myint and Charles Suggs catch up with Sean Moriarity, co-creator of the Nx project and author of Machine Learning in Elixir. Sean reflects on his transition from the military to a civilian job building large language models (LLMs) for software. He explains how the Elixir ML landscape has evolved since the rise of ChatGPT, shifting from building native model implementations toward orchestrating best-in-class tools.
We discuss the pragmatics of adding ML to Elixir apps: when to start with out-of-the-box LLMs vs. rolling your own, how to hook into Python-based libraries, and how to tap Elixir’s distributed computing for scalable workloads. Sean closes with advice for developers embarking on Elixir ML projects, from picking motivating use cases to experimenting with domain-specific languages for AI-driven workflows.
Key topics discussed in this episode:
The evolution of the Nx (Numerical Elixir) project and what's new with ML in Elixir
Treating Elixir as an orchestration layer for external ML tools
When to rely on off-the-shelf LLMs vs. custom models
Strategies for integrating Elixir with Python-based ML libraries
Leveraging Elixir’s distributed computing strengths for ML tasks
Starting ML projects with existing data considerations
Synthetic data generation using large language models
Exploring DSLs to streamline AI-powered business logic
Balancing custom frameworks and service-based approaches in production
Pragmatic advice for getting started with ML in Elixir
Links mentioned:
https://hexdocs.pm/nx/intro-to-nx.html
https://pragprog.com/titles/smelixir/machine-learning-in-elixir/
https://magic.dev/
https://smartlogic.io/podcast/elixir-wizards/s10-e10-sean-moriarity-machine-learning-elixir/
Pragmatic Bookshelf: https://pragprog.com/
ONNX Runtime Bindings for Elixir: https://github.com/elixir-nx/ortex
https://github.com/elixir-nx/bumblebee
Silero Voice Activity Detector: https://github.com/snakers4/silero-vad
Paulo Valente Graph Splitting Article: https://dockyard.com/blog/2024/11/06/2024/nx-sharding-update-part-1
Thomas Millar's Twitter https://x.com/thmsmlr
https://github.com/thmsmlr/instructorex
https://phoenix.new/
https://tidewave.ai/
https://en.wikipedia.org/wiki/BERT(language_model)
Talk: PyTorch: Fast Differentiable Dynamic Graphs in Python (https://www.youtube.com/watch?v=am895oU6mmY) by Soumith Chintala
https://hexdocs.pm/axon/Axon.html
https://hexdocs.pm/exla/EXLA.html
VLM (Vision Language Models Explained): https://huggingface.co/blog/vlms
https://github.com/ggml-org/llama.cpp
Vector Search in Elixir: https://github.com/elixir-nx/hnswlib
https://www.amplified.ai/
Llama 4 https://mistral.ai/
Mistral Open-Source LLMs: https://mistral.ai/
https://github.com/openai/whisper
Elixir Wizards Season 5: Adopting Elixir https://smartlogic.io/podcast/elixir-wizards/season-five
https://docs.ray.io/en/latest/ray-overview/index.html
https://hexdocs.pm/flame/FLAME.html
https://firecracker-microvm.github.io/
https://fly.io/
https://kubernetes.io/
WireGuard VPNs https://www.wireguard.com/
https://hexdocs.pm/phoenixpubsub/Phoenix.PubSub.html
https://www.manning.com/books/deep-learning-with-python
Code BEAM 2025 Keynote: Designing LLM Native Systems - Sean Moriarity
Ash Framework https://ash-hq.org/
Sean’s Twitter: https://x.com/seanmoriarity
Sean’s Personal Blog: https://seanmoriarity.com/
Erlang Ecosystems Foundation Slack: https://erlef.org/slack-invite/erlef
Elixir Forum https://elixirforum.com/
Sean’s LinkedIn: https://www.linkedin.com/in/sean-m-ba231a149/
Special Guest: Sean Moriarity.
--------
44:21
LangChain: LLM Integration for Elixir Apps with Mark Ericksen
Mark Ericksen, creator of the Elixir LangChain framework, joins the Elixir Wizards to talk about LLM integration in Elixir apps. He explains how LangChain abstracts away the quirks of different AI providers (OpenAI, Anthropic’s Claude, Google’s Gemini) so you can work with any LLM in one more consistent API. We dig into core features like conversation chaining, tool execution, automatic retries, and production-grade fallback strategies.
Mark shares his experiences maintaining LangChain in a fast-moving AI world: how it shields developers from API drift, manages token budgets, and handles rate limits and outages. He also reveals testing tactics for non-deterministic AI outputs, configuration tips for custom authentication, and the highlights of the new v0.4 release, including “content parts” support for thinking-style models.
Key topics discussed in this episode:
• Abstracting LLM APIs behind a unified Elixir interface
• Building and managing conversation chains across multiple models
• Exposing application functionality to LLMs through tool integrations
• Automatic retries and fallback chains for production resilience
• Supporting a variety of LLM providers
• Tracking and optimizing token usage for cost control
• Configuring API keys, authentication, and provider-specific settings
• Handling rate limits and service outages with degradation
• Processing multimodal inputs (text, images) in Langchain workflows
• Extracting structured data from unstructured LLM responses
• Leveraging “content parts” in v0.4 for advanced thinking-model support
• Debugging LLM interactions using verbose logging and telemetry
• Kickstarting experiments in LiveBook notebooks and demos
• Comparing Elixir LangChain to the original Python implementation
• Crafting human-in-the-loop workflows for interactive AI features
• Integrating Langchain with the Ash framework for chat-driven interfaces
• Contributing to open-source LLM adapters and staying ahead of API changes
• Building fallback chains (e.g., OpenAI → Azure) for seamless continuity
• Embedding business logic decisions directly into AI-powered tools
• Summarization techniques for token efficiency in ongoing conversations
• Batch processing tactics to leverage lower-cost API rate tiers
• Real-world lessons on maintaining uptime amid LLM service disruptions
Links mentioned:
https://rubyonrails.org/
https://fly.io/
https://zionnationalpark.com/
https://podcast.thinkingelixir.com/
https://github.com/brainlid/langchain
https://openai.com/
https://claude.ai/
https://gemini.google.com/
https://www.anthropic.com/
Vertex AI Studio https://cloud.google.com/generative-ai-studio
https://www.perplexity.ai/
https://azure.microsoft.com/
https://hexdocs.pm/ecto/Ecto.html
https://oban.pro/
Chris McCord’s ElixirConf EU 2025 Talk https://www.youtube.com/watch?v=ojL_VHc4gLk
Getting started:
https://hexdocs.pm/langchain/gettingstarted.html
https://ash-hq.org/
https://hex.pm/packages/langchain
https://hexdocs.pm/igniter/readme.html
https://www.youtube.com/watch?v=WM9iQlQSFg
@brainlid on Twitter and BlueSky Special Guest: Mark Ericksen.
--------
38:18
Blue Heron: Bluetooth Low Energy (BLE) for Elixir & Nerves with Connor Rigby
Connor Rigby joins the Elixir Wizards to talk about Blue Heron BLE (Bluetooth Low Energy) support for Elixir apps. Blue Heron implements the BLE specs in pure Elixir, leveraging binary pattern matching and concurrent message processing to handle Bluetooth protocols. Unlike most solutions that require C ports or NIFs, Blue Heron runs entirely in user space, so it works seamlessly in both Nerves-based embedded projects and (eventually) desktop Elixir applications.
We discuss how Nerves development differs from building Phoenix apps. Connor shares challenges he's experienced with hardware compatibility, where some chips only partially implement the spec, and he discusses the surprisingly deep (but sometimes incomplete) world of BLE device profiles. His tip for anyone entering the BLE space: read the official spec instead of trusting secondhand blog posts. Tools like Nerves LiveBook give you hands-on examples, so you can get a BLE prototype running on a Raspberry Pi and your phone in no time.
Key topics discussed in this episode:
Blue Heron origins and “bird” naming convention
BLE vs. Bluetooth Classic: core differences
Pure Elixir implementation—no C dependencies
Binary pattern matching for packet parsing
Hardware transport options: UART, SPI, USB, SDIO
GenServer patterns in Nerves vs. Phoenix
Linux requirement and power-consumption trade-offs
GATT (Generic Attribute Table) implementation patterns
SQLite integration for Nerves apps
Hardware chip quirks and spec compliance
Manufacturer-specific commands and workarounds
BLE device profiles and spec gaps
Security Management Profile (SMP) for encryption
Device connection and pairing workflows
Web vs. embedded development differences
Where to get started: hardware recommendations and docs
Links mentioned:
https://github.com/ConnorRigby/
https://github.com/blue-heron/
https://nerves-project.org/
BLE (Bluetooth Low Energy) https://en.wikipedia.org/wiki/BluetoothLowEnergy
https://developer.apple.com/ibeacon/
https://learnyousomeerlang.com/building-otp-applications
Linux https://www.linux.org/
HCI (Host Controller Interface) https://en.wikipedia.org/wiki/Hostcontrollerinterface
Circuits UART Library https://hexdocs.pm/circuitsuart/readme.html
SPI (Serial Peripheral Interface) https://github.com/elixir-circuits/circuitsspi
SDIO (Secure Digital Input Output https://en.wikipedia.org/wiki/SDIO
Raspberry Pi https://www.raspberrypi.com/
Coral SoM Dev Board https://coral.ai/products/dev-board/
BeagleBone Single-Board Linux Computer https://www.beagleboard.org/boards/beaglebone-black
https://www.bluetooth.com/bluetooth-resources/intro-to-bluetooth-gap-gatt/
Genservers https://hexdocs.pm/elixir/1.12/GenServer.html
https://hexdocs.pm/ecto/Ecto.html
https://github.com/elixir-sqlite/ectosqlite3
https://github.com/nerves-livebook/nerveslivebook Special Guest: Connor Rigby.
--------
46:16
Zigler: Zig NIFs for Elixir with Isaac Yonemoto
In the Season 14 premiere, hosts Dan Ivovich and Sundi Myint chat with Isaac Yonemoto, creator of the Zigler library, to explore how Zigler brings Zig’s performance and safety to Elixir through Native Implemented Functions (NIFs). Isaac walks through the core design of Zigler and how it auto-generates the Elixir-to-Zig bridge, enforces type safety, and exposes multiple execution modes (normal, dirty, threaded). The conversation covers real-world applications, from SIMD-powered token selection for LLM hardware acceleration to OTP-style fault tolerance in low-level code.
Isaac shares his own journey: stepping back from professional software work to launch a biotech startup focused on reducing drug manufacturing costs while continuing to maintain Zigler and even leveraging Elixir for bioinformatics pipelines.
Topics discussed in this episode:
What is the Zigler library and what does it do?
What does it mean to run a "dirty NIF"?
Async mode is temporarily removed from Zig (therefore, yielding NIFs is temporarily deprecated in Zigler)
Zigler’s three execution modes (normal, dirty, and threaded) and how you switch modes with a single config change
Isaac’s journey from professional software work to launching a biotech startup
How Isaac leverages Elixir in bioinformatics pipelines at his startup
LLM hardware acceleration using Zigler NIFs and SIMD-powered token picking
Fault-tolerant load balancing of NIF workloads via OTP principles
Transparent handling and recovery from hardware failures through monitoring
Potential future memory-safety features in Zig and their implications
The Elixir-based borrow-checker prototype: purpose and design
Unit-checking for scientific computations to enforce correctness
New OS support in Zigler 0.14: macOS, Windows, and FreeBSD
Inline Zig code authoring directly within Elixir modules
Isaac's commitment to maintain Zigler through its 1.0 release (...and beyond?)
Links mentioned:
https://github.com/E-xyza/zigler
https://github.com/ziglang/zig
https://vidalalabs.com/
Zig Programming Language: https://ziglang.org/
https://obsidian.md/
https://hexdocs.pm/elixir/macros.html
https://erlang.org/documentation/doc-4.7.3/doc/extensions/macros.html
A Deep Dive Into the Elixir AST: https://dorgan.ar/posts/2021/04/theelixirast/
https://www.erlang.org/doc/system/nif.html
https://nodejs.org/en
Llama Open-Source LLM: https://www.llama.com/
Mixtral Open-Source LLM: https://mistral.ai/news/mixtral-of-experts
https://Fly.io
SIMD: https://en.wikipedia.org/wiki/Singleinstruction,multiple_data
https://opentrons.com/
CI/CD: https://en.wikipedia.org/wiki/CI/CD
https://hexdocs.pm/zigler/Zig.html
http://www.x.com/DNAutics
https://bsky.app/profile/dnautics.bsky.social
Elixir Wizards is an interview-style podcast for anyone interested in functional programming and the Elixir Programming Language. Hosted by SmartLogic engineers and Elixirists Owen Bickford, Dan Ivovich, and Sundi Myint, this show features in-depth discussions with some of the brightest minds in the industry, discussing training and documentation in Phoenix LiveView, the evolution of programming languages, Erlang VM, and more.
In the current season, we're branching out from Elixir to compare notes with thought leaders and software engineers from programming languages like JavaScript, Ruby on Rails, Go, Scala, Java, and more. Each episode will take a deep dive into a topic from Machine Learning and AI, to ECS and game development, to education and community.
Learn more about how SmartLogic uses Phoenix and Elixir. (https://smartlogic.io/phoenix-and-elixir?utm_source=podcast)