Generating Fractals in the Browser With Rust and WebAssembly
Ankur Sethi
@s3thi
WebAssembly is a low-level instruction format designed to be a compilation target for systems programming languages such as C, C++, and Rust. Code compiled to WebAssembly executes at near-native speeds, allowing you to write performance-critical parts of your JavaScript application in a lower-level language for a significant performance boost.
In this talk, I will walk you through writing an application that generates a Mandlebrot fractal in the browser. I’ll use React for building the user interface, and Rust for generating the fractal.
Outline
WebAssembly is a low-level instruction format designed specifically to be a compilation target for systems programming languages. It is currently supported across all modern browsers, including Chrome, Firefox, Edge, and Safari. This gives us another method for optimizing and speeding up our Web applications by re-writing their performance-critical parts in a language designed to prioritize raw execution speed.
Rust is one such language. It is a safe, concurrent, and fast programming language developed by Mozilla for the Servo browser engine. Designed as a practical replacement for C and C++, it’s used in production as a part of Firefox’s rendering pipeline. Other users of Rust include Figma, Deliveroo, and Microsoft.
In this talk, I will walk you through writing an application that generates a Mandlebrot fractal in the browser. I’ll use React for building the user interface, and Rust for generating the fractal.
Here is an outline of my talk:
- What is the Mandlebrot set? How do I render one?
- What is WebAssembly? What is it good for?
- How do I run WebAssembly in my browser?
- What is Rust?
- How do I compile Rust to WebAssembly?
- How do I write the performance-critical part of my JavaScript program in Rust?
- Why can’t I write my entire application in Rust?
You don’t have to be familiar with either Rust or WebAssembly to attend this talk.
Speaker bio
Ankur Sethi leads the Web Engineering team at Uncommon in Bangalore. He builds applications with JavaScript, TypeScript, and (sometimes) Rust. He has terrible taste in music, which he inflicts on unsuspecting strangers if handed the AUX cord at parties.
Links
- My website and blog: https://ankursethi.in
- My previous talk at JSFoo 2016: https://www.youtube.com/watch?v=X8uMg-VwJS8
- My Medium profile (where I only post occasionally): https://medium.com/@ankurs3thi
- My Twitter profile (mostly me complaining about things): https://twitter.com/ankurs3thi
{{ errorMsg }}