BAML overview: Rust-inspired types and Python interop
Vaibhav Gupta explains BAML's inferred error types, callable functions and Python bindings, with a live demo that encounters a compiler bug.
Player not loading? Watch on YouTube
Vaibhav Gupta presents BAML at the Seattle Rust User Group as a language built in Rust for code that AI writes and humans need to understand. His stated goal is familiar TypeScript-like syntax with stronger guarantees, drawing on Rust's approach to types.
The presentation covers clickable diagrams linked to source lines and a describe command that uses the abstract syntax tree to return relevant code context. Gupta also demonstrates calling individual functions directly and describes packaging a function as a standalone binary with a choice of target architecture.
Error handling takes much of the talk. Gupta explains that the compiler infers thrown value types, while an optional throws annotation constrains a function's public contract. Examples cover catching specific error types, unreachable handlers and inference through callbacks. He compares this approach with Rust result types and Java's explicit throws declarations.
The interoperability demo uses generated Python bindings and passes Python callbacks into the language. He describes C++ support as forthcoming and says calling arbitrary Rust code is not supported in practice yet.
The closing discussion covers interfaces and concurrency through spawn. Gupta explains a restriction intended to prevent unsafe narrowing of captured union values, but the live example encounters a compiler bug. These are the speaker's demonstrations and design claims, rather than independent verification of the language's guarantees.