In 2020, I was lucky enough to give two presentations on the Rust programming language. The first talk was at Adobe Research, and the second was to the excellent Desert Rust Arizona-based developer group.
The topic of both presentations was to create correct, efficient solutions to problems as a Rust library. Specifically, this library should be designed to be as reusable as possible in other languages, using Rust’s robust FFI facilities. As an example problem, I chose to generate the Mandelbrot set. This problem is a good example for three reasons:
- It is highly parallel.
- Computing large sets is computationally expensive.
- The solution does not have dependencies that break/degrade across the FFI boundary.
I decided that the best way to convince the audience about the FFI capabilities of Rust was to actually use them. To that end, I created a Mandelbrot set common library in Rust, creatively called
mandelbrot_common. This library is published on crates.io, and the source code is published on GitHub.
I then created a Python package which integrated this library, returning the Mandelbrot set as a
numpy.ndarray. I accomplished this by using the Rust/Python FFI library PyO3, managed by the maturin package. This package, creatively called
mandelbrot_py, is published on pypi.org. The source code is published on GitHub.
I also created a demo Jupyter notebook hosted with the Jupyter Binder service. This notebook allows users to interact with the Python package and view the resulting images.
mandelbrot_common library to WebAssembly. The application is then able to use the
The presentation itself
The slides for the presentation are available at:
I do not (currently) have a recorded version of the talk. However, the minutes from the Desert Rust meetup are available at:
The Mandelbrot webapp
Thanks to the magic of
iframe, I can directly embed the webapp on this project page. If you’re able to play with the sliders below, then you’re using an application written in Rust and compiled to WebAssembly!