Write Your First WASM Module using Rust
Вставка
- Опубліковано 24 січ 2022
- Get on the bleeding edge with a basic WebAssembly module written in Rust and compiled with wasm-pack.
/ crim_codes
austincrim.com
rust-lang.org
rustwasm.github.io/wasm-pack/
www.python.org/downloads/
if you don't like light mode, put on sunglasses
😂😂😜
simply invert colours on your display
You should have added 😎 to your comment
There is a lack of documentation on some of this stuff in rust. You sir, are my hero!
Man thank you so much, I'm just getting started with rust wasm and this is so helpful
This is super clear and succinct, great video, Austin!
This is so much easier than I even thought! Thanks for demystifying.
I am a JS dev and already started to learn Rust. And knowing there is such a great way to combine the simplicity of JS with the power of Rust... Oh, I am really excited to write my next developer tools on Rust!
The hard part is integrating Wasm with Node.js and npm. I finally got it to work after 2 full days of trying stuff, and now I decide I want to use Vite, and it's the same nightmare all over again...
Once you get it setup, it works like a charm though!
@@carlosmspk Why is it so hard? Node supports wasm out of the box. And in Rust side you have wasm_bindgen to use Node API. I've also seen people compile Rust directly to N-API addons, but I am not sure it is a good idea
@@phoenix-tt All of that stuff is true, but "out of the box" still requires configuring if you're using bundlers and whatnot. I was using WebPack 5.x and it does not allow Wasm by default, had to toggle asyncWebassembly in experimental features. Then, with vite, the procedure is different. Truth be told, I'm new to web development, I came from Rust trying to make an UI to it, and I literally just learned JS 2 months ago, so that's probably why I struggled so much with it...
Great stuff! Needed to get my existing Rust lib to wasm and the templatized methods generally prescribed seemed too painful but this one was perfect!
Really cool! Thanks for the WASM module using Rust tutorial. Consider me your subscriber
You are amazing man thank you soooo much.
Great video 💯
Truly good. Hey, i saw your svelte video. Please consider make a video of Svelte + Vite + WASM + Rust.
That will be a lethal combo.
I feel cutting edge now, thanks for the great tutorial!
Yes, the basic examples work fine. The challenge is with using advanced Rust stuff like struct, vectors, etc. How is borrowing handled in wasm?
All native Rust types are automagically translated from Js. Vecs are Arrays, string slices are strings, numbers are converted accordingly, etc.
Structs can be automatically serialized into Json using the serde crate, and in the Rust function signature, you use the wasm_bindgen type JsValue. Borrowing is irrelevant, that mechanism only works inside Rust and is assured at compile time, once the .wasm file is generated, it is no longer relevant
You first learn rust and then do wasm.
Quality content
Love the tutorial! Since this seems to be targeted at complete new users to rust it might be good to show where the cargo website is and where to the current version number is so they don't try using old out of date packages. other then that it was great!
Great point! I’ll be sure to include versions in future videos.
Thanks for that. Short and communicative. Will you do more of this staff?
Yeah! I don’t have a regular cadence yet, but I’m hoping to post more consistently over the coming months.
can we use LiveServer extension to run as our web server for this project?
So the add function implementation a+b is not visible to anyone?
Tested adding an entry to the Htaccess file in my bluehost account and was able to serve them from there.
Which theme do you use for your iTerm ?
You need to learn how to use the zoom feature of the screen recorder and VSCode. The text or code are too tiny!
Nice! Can you make more videos on WASM...
Maybe! I plan to just make videos on whatever I’m currently learning 😁.
How do you set the correct MIME type? My file won't load in the browser
It depends on what you’re using as your server. It works out of the box with the built-in Python server in the video. Other servers must support the `application/wasm` MIME type.
Thanks for this. The "official" rust-wasm book is super outdated and a frustrating experience to try and implement (with webpack and other nonsense that no longer works).
What VSCode theme are you using?
GitHub Light
Quick question, is it possible to create Desktop Environment, like Gnome, KDE for linux, using WASM?
TTP -> to the point
pls make fonts mobile friendly
Nice tutorial, but now my eyes burn...
darkmode bro. Youre welcome