Categories
Web Development

An explainer about Rust, Web Assembly, the future, and a concern

What is Rust and what does it have to do with the future of the web? I’ve noticed some buzz about Rust lately and wanted to write this explainer post to share my distillation of the topic.

Who is this post for?

This post is for informally educated web designers and developers like me who avoid, or previously avoided, topics that seem computer science-y. Maybe you saw something about Rust or Web Assembly and thought, “not for me”. I hear that, but I also want to say…it might be for you (and for me)!

What is Rust?

Rust is a systems programming language, generally meaning it deals with machine-level details like memory management (JavaScript, for example, does this automatically). Rust is growing in popularity compared to other systems programming languages because it contains additional features that make it easier to write secure and performant code, and it is supported by an active community.

What’s up with the future?

I recently read a post titled Rust is the Future of JavaScript Infrastructure. Despite this proclamatory title, Rust is not for sure the future of JavaScript infrastructure. But this did get me thinking. There are some big developments in web technology that mean Rust and other languages, like Go, for instance, could play a bigger role in the future of web development, or at least in the source of our tools.

The first development is in the maturity of the aforementioned JavaScript infrastructure. JavaScript is everywhere and it requires an increasing amount of JavaScript to write JavaScript, HTML, or CSS as the web development ecosystem evolves. Authoring some of this JavaScript in a language such as Rust would mean the build tools we use to write JavaScript may run faster and may be easier to install.

Another big development is Web Assembly, also known as WASM.

What is Web Assembly (WASM)?

Generally speaking, assembly language is similar to machine language, but where certain collections of characters are replaced with more human-friendly words. Assembly language is a low-level language, meaning programming languages humans write are compiled to assembly language, and these instructions are read directly by a machine. Web assembly is the same concept, but for a browser. The idea is that you can author a program in any programming language, and that language could be compiled to an assembly language that can be executed by the browser. The compiled code is output to a .wasm file. This means that, in theory, any language could run in the browser if it compiles to a .wasm file. I think about it like this:

At the top is a title "Programming Languages A Browser Can Understand". On the left is a blue monster that is a metaphor for the browser. There are arrows for HTML, CSS, and JS pointing to its mouth. On the right is the same image but with an additional arrow "wasm" with an arrow poiting toward it that says "any language".
The difference between programming languages that can be used on the web before and after Web Assembly.

Here is a helpful, 100 second explainer about WASM that goes into some more detail.

What is my concern?

People enter web development from all sorts of avenues, and they grow into all sorts of careers. One avenue for growth in my career was through open source contribution, which grew from the ability to look into the source of the frameworks and build tools I use in my day-to-day work. Almost all of these tools are written in Node.js, the implementation of JavaScript that can be run outside of the browser. I was able to gradually find my way into contributing to these tools and building some of my own as I learned from my studying these tools’ sources. While the JavaScript in the source of these tools was quite different from what I knew, the fact that it was the same language meant I had a significant “foot in the door” that got me started discovering new knowledge through my existing knowledge.

Now, let’s pretend all of these tools are written in Rust. The source of the open-source tools now has very little in common with the languages I know for my work, and this particular pathway I used to further my technical knowledge as a self-taught web developer may no longer exist.

What am I really saying?

I’m talking about power structures. Who already has the knowledge required to program in Rust? Who has the resources to obtain that knowledge? Who doesn’t? In the last decade, it was an alienating change for many people to require knowledge of JavaScript, and increasingly various frameworks and Typescript, to use the tools required to build for the web. Are we going in the direction of requiring knowledge of a systems programming language to grow through contribution to open source web tools?

I want to emphasize that this comment isn’t directed toward Rust or the Rust community, but a comment about the potential consequences for who gets to be a programmer in a world where performance is valued above all else in the tools and languages we use.

It’s entirely possible that the gap I anticipate between web development knowledge and Rust knowledge isn’t as vast as I think. The Rust community looks like it has a wealth of introductory learning tools. Learning a bit of Rust has been on my to-do list for two years – maybe 2022 is the year?

Would you, reader, be interested in a “Web Developers Learning Rust Together” virtual meetup kind of thing? Send me an email, if so. Disclaimer: I have no idea if I will actually organize something around this, but I like the idea!