Why is Rust interesting for WebDevelopers?

One (combined) word: WebAssembly!

🧵🔽
1️⃣ Why Is This Interesting At All?

WebAssembly has the chance to become for JavaScript what C, C++, and Fortran are for Python.

JavaScript has its limitations, as well as Python does. Python solves this by having an awesome native interface that allows easy integration ...
... of low-level libraries. JavaScript has C/C++ in Node. But in the browser? Sure, floating-point arithmetics can well be done with the help of WebGL and shader language, but there is no common low-level target for all of JavaScript.
This is where WebAssembly comes in. It could solve many of the problems one might run into when doing some heavy number crunching or string manipulation on a huge scale.

When you reach a hot path that you cannot or don't want to optimize any further, but which still ...
... isn't fast enough, you could swap this path out for an implementation in WebAssembly, and (hypothetically) gain a lot of performance.

This comes at the cost of switching languages, but perhaps preserves the benefit of readable code. The choice is up to you.
2️⃣ Okay, What Is WebAssembly?

WebAssembly (short WASM) is a byte code that can be processed and executed by a runtime. This runtime is built into most modern browsers and is also a part of Node.

It comes with a language that can be read by humans and a byte code that ...
... is optimized for being executed by runtimes and is especially meant as a compile target. You won't write WebAssembly yourself, although you could. You usually write code in a language you are comfortable with and then compile it down to WASM.
3️⃣ What Has Rust To Do With It?

Glad you ask! WASM is a first-class citizen of Rust. The tooling is mature and plentiful and the resulting binary code is actually one of the fastest and most efficient put out by any compiler currently on the market.
Take a look at the code below. That's everything. And yes, it does exactly what you might expect it to do!

When you compile this with the proper tooling you get:

- A WASM file containing the compiled code
- A JS file as an importable module
- A *.d.ts file for TS types Image
You could even pack this into an npm module and then import it into your own project. You won't have to deal with much integration work, only with the code you write. That's the awesome thing about Rust and its WASM tooling. After compilation, it's usable directly.
4️⃣ How To Get Started?

Rust has a book for everything. No difference for WASM.

The Rust WASM book is a great first entry into Rust and WebAsembly in combination with web development.

rustwasm.github.io/docs/book/
5️⃣ Anything Else I Can Profit From?

Yes. WebAssembly is currently on its way to become a universal bytecode not only for web development but also for many more things.

There is a universal WASM runtime now, you can create smart contracts with it (Elrond), you can ...
... run it directly in Kubernetes (Krustlet), and so on.

There are even more experiments going on right now which might lead to WebAssembly really gaining speed and traction.

Knowing a language that easily compiles down to it could be pretty beneficial in the long run!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Oliver Jumpertz

Oliver Jumpertz Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @oliverjumpertz

22 Mar
Test-Driven Development

You hear some people talking about it, you might have a basic idea, but let's take a closer look because, in the end, it's not as difficult as it might seem from the outside!

🧵⏬
1️⃣ What Is It?

Test-driven development (short: TDD) is a software development technique.

Instead of writing all your code first and only then writing your tests, you start with tests, then code a little, then test again, and so on.
It is one specific form of the test-first approach and aims at making software development faster, more reliable, and safer to do. And it especially forces developers into a user role.

By writing tests first, you become a user. You are the first one to ...
Read 26 tweets
21 Mar
So many people say "learn the fundamentals", but sometimes it's difficult as a beginner to even remotely grasp what that means. And that's okay.

Let's talk about it, and let me give you some info on it (from my point of view).

🧵⏬
1️⃣ What Actually Are Fundamentals?

Fundamentals are concepts, and maybe even techniques, that you can apply in multiple areas and multiple programming languages.

They are not tied to anything specific and are sometimes pretty theoretical.
All in all, they are the foundation you can base more specific knowledge on.

All programming languages build on those fundamentals themselves and give you a very specific way to work with them.
Read 30 tweets
20 Mar
JavaScript keeps evolving every day, and there are many proposals currently in the pipeline that are going to make JavaScript even more awesome! 🔥

We'll take a look at one proposal that is currently in stage 2 and is going to bring native immutability to JS!

🧵⏬
1️⃣ The Records & Tuple Proposal

This proposal introduces two new types to JavaScript, namely Record and Tuple.

They are designed as compound primitives that can contain other (compound) primitives.

github.com/tc39/proposal-…
They are both deeply immutable, so you no longer need to Object .freeze() your objects or use libraries like Immutable .js to gain unchangeable objects, and do you know what's even more awesome?

You can compare them with the strict equality comparison (===), ...
Read 18 tweets
17 Mar
Want to get started with Rust?

Here are some resources that help you to get into the language!

🧵⬇️
1️⃣ "The Book"

This is the official Rust book. It covers everything the language has to offer and introduces feature after feature while enabling especially newbies to follow along from the simpler to the more difficult topics.

doc.rust-lang.org/book/
2️⃣ Rustlings

This project gives you small exercises that aim at getting you comfortable writing Rust code. Especially if you don't feel creative enough to think of a new project, this is a great way of still writing code.

github.com/rust-lang/rust…
Read 8 tweets
16 Mar
Let's talk about Rust.

The most-loved language, according to StackOverflow's yearly developer survey that not enough people seem to use professionally.

🧵⏬
1️⃣ What Is Rust?

Rust is a systems programming language that is compiled to binary. It has no runtime and instead uses a concept called "borrow checking". Developers don't need to explicitly free memory, the compiler does it for them.
The language itself is multi-paradigm, offering functional, generic, imperative, structured, and concurrent programming with a huge emphasis on performance, memory safety, and developer productivity.
Read 26 tweets
15 Mar
What are NFTs? Everyone seems to be talking about them but what are they, and how can you use them?

Interested? Then this thread is for you!

🧵🔽
1️⃣ What Is An NFT?

Non-fungible tokens (NFTs) are digital assets. Just imagine a trading card where each card has unique information engraved into it. No two NFTs are the same and they are thus not interchangeable.
Other than crypto where one BTC is one and two BTC are two BTC, two NFTs are one NFT and one NFT. Only because you have two NFTs of the same type simply doesn't enable you to sum them up together.
Read 19 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!