Why I'm finally learning Rust

Javascript and its derivatives are immensely flexible. I've used some variation of Javascript for pretty much every use case you can think of - desktop applications, mobile apps, APIs and entire backend processing systems. You can train a complete newbie on the basics incredibly quickly, and I love working with it. I've primarily been a Javascript developer my entire career and I started using typescript when I joined Pretty Little Thing back in 2020. I've been a big fan of the support that having a typed version of Javascript offers and you'll find almost all my blog posts use typescript in some capacity. Be that as it may, currently I find myself spending my weekends learning Rust.

Like Java, C and many other languages, Rust is a statically typed language. That is to say that you know what form a variable will take explicitly before you ever run your code. If you're coming from typescript then you're familiar with the principal, even if it is a little stricter than you're used to.

Rust allows you direct access to memory in much the same way that you can in C or C++, but like JS, it has garbage collection. Unlike other languages, however, Rust takes a unique approach to its memory management. It aggressively removes data from memory based on the idea of "ownership". Rust keeps track of what part of your code "owns" the variable, and which have "borrowed" it. If the owner is no longer running and no other part of the code is currently borrowing it, then the variable is removed from memory; freeing it up for other uses.

In 2021's Stack Overflow Developer Survey Javascript was listed as the world's most popular language, with 64.96% of users using it. Typescript also had a massive 30.19% of its own. Rust on the other hand was listed as a known language for only 7.03% of respondents. That's up from 5.1% in 2020's Survey, showing that Rust is gaining traction quickly with the over 80,000 developers that answer the survey each year.

Rust 1.0 came out May 15th 2015, after starting life as yet another piece of tech from the bowels of Mozzila personal projects over 10 years earlier (2006). You'd be forgiven for thinking it was a recent invention given the increase in hype during the last couple of years but I suppose that's because the Rust Foundation (Founded by Amazon, Huawei, Google, Microsoft and Mozilla in 2021) has proved incredibly successful. That is to say, Rust has a pedigree that many wouldn't even have considered.

In April of 2021, Google announced in a blog post that the Android platform would also begin to use Rust for the further development of their operating system due to its improvements in type and memory safety over C++.

On a slightly tangential note, which I promise will be relevant once I explain it, Web Assembly has proved massively powerful, in part due to projects like emscripten which allows other languages to be compiled to web assembly. This has resulted in many compiled languages being able to be used as part of web frontends alongside regular JS.

Interestingly, you don't even have to learn Rust to start using it. It's already finding a home within Javascript stacks via projects like SWC (Speedy Web Compiler) which we're using within our team at PLT to significantly improve the speed of our many typescript bundles.

That is to say that at this point in time, Rust is being used right across the stack in much the same way that JS is. It's making it's way into the code bases of those who don't know a line of Rust and it's only gaining traction. If you have the time and are willing, I'd suggest that as a javascript developer it's a natural extension to start learning.

github issue

Webmentions

What's this?

This site uses Webmentions to handle likes, comments and other interactions. To leave a comment, you can reply on GitHub, or Reddit. While the site will count likes from any source, only twitter likes are currently displayed in the facepile.