How To Quickly Optimize JavaScript Code with Rust
Speed up your JavaScript
Introduction
Rust is is a low-level language that is strongly typed. Like C/C++, Rust can take full advantage of a machine’s processing power to create systems that are highly performative. It’s also safe. What Rust promises is C++ control without all of the security troublemakers like segfaults, null pointers, buffer overflows, and many other nightmares that C++ developers have to wrangle with.
Rust’s safety, combined with its modularity, makes it suitable for integration with other languages. Thanks to its easy to implement multi threading, we can drastically speed up our single-threaded JavaScript apps.
We’re going to walk through setting up Rust, writing Rust code, exporting the code, and using the code in our Node environment. By the end of this article, you’ll see how painless marrying Rust with JavaScript is.
In the future, we’ll be tackling concurrency, threads, and various other optimization techniques that will inevitably prove that Rust can find a home in our JavaScript code.
Step 1 — Set up up Node and Rust
In this part of the series we’ll be working with a simple iterative factorial solution written in Rust. Using iteration will allow us to…