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/

КОМЕНТАРІ • 42

  • @AustinCrim
    @AustinCrim  2 роки тому +57

    if you don't like light mode, put on sunglasses

  • @SerHanmer
    @SerHanmer Рік тому +9

    There is a lack of documentation on some of this stuff in rust. You sir, are my hero!

  • @loryhoof
    @loryhoof 2 місяці тому

    Man thank you so much, I'm just getting started with rust wasm and this is so helpful

  • @TrostCodes
    @TrostCodes 2 роки тому +4

    This is super clear and succinct, great video, Austin!

  • @phoenix-tt
    @phoenix-tt 2 роки тому +10

    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!

    • @carlosmspk
      @carlosmspk 2 роки тому +1

      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!

    • @phoenix-tt
      @phoenix-tt 2 роки тому

      @@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

    • @carlosmspk
      @carlosmspk 2 роки тому

      @@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...

  • @shreepads
    @shreepads Рік тому +1

    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!

  • @Zealwind
    @Zealwind 2 роки тому +1

    Really cool! Thanks for the WASM module using Rust tutorial. Consider me your subscriber

  • @boomshakalaka656
    @boomshakalaka656 10 місяців тому

    You are amazing man thank you soooo much.

  • @yassin_eldeeb
    @yassin_eldeeb 2 роки тому +1

    Great video 💯

  • @bobbradleybell
    @bobbradleybell 2 роки тому +3

    Truly good. Hey, i saw your svelte video. Please consider make a video of Svelte + Vite + WASM + Rust.
    That will be a lethal combo.

  • @Parkuman
    @Parkuman 2 роки тому +1

    I feel cutting edge now, thanks for the great tutorial!

  • @0xedb
    @0xedb 2 роки тому +11

    Yes, the basic examples work fine. The challenge is with using advanced Rust stuff like struct, vectors, etc. How is borrowing handled in wasm?

    • @carlosmspk
      @carlosmspk 2 роки тому +4

      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

    • @alemartinezz1022
      @alemartinezz1022 2 роки тому

      You first learn rust and then do wasm.

  • @tawandagamedevs
    @tawandagamedevs 2 роки тому

    Quality content

  • @owenquinlan6047
    @owenquinlan6047 2 роки тому +2

    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!

    • @AustinCrim
      @AustinCrim  2 роки тому

      Great point! I’ll be sure to include versions in future videos.

  • @marcingil7425
    @marcingil7425 2 роки тому +2

    Thanks for that. Short and communicative. Will you do more of this staff?

    • @AustinCrim
      @AustinCrim  2 роки тому +2

      Yeah! I don’t have a regular cadence yet, but I’m hoping to post more consistently over the coming months.

  • @h.jpouya4715
    @h.jpouya4715 2 роки тому +1

    can we use LiveServer extension to run as our web server for this project?

  • @puniith8246
    @puniith8246 5 місяців тому

    So the add function implementation a+b is not visible to anyone?

  • @brianedwards30
    @brianedwards30 Рік тому

    Tested adding an entry to the Htaccess file in my bluehost account and was able to serve them from there.

  • @RajeshSamson
    @RajeshSamson 2 роки тому

    Which theme do you use for your iTerm ?

  • @DeLaCruzer11
    @DeLaCruzer11 3 місяці тому

    You need to learn how to use the zoom feature of the screen recorder and VSCode. The text or code are too tiny!

  • @saathwik_dasari1
    @saathwik_dasari1 2 роки тому +2

    Nice! Can you make more videos on WASM...

    • @AustinCrim
      @AustinCrim  2 роки тому

      Maybe! I plan to just make videos on whatever I’m currently learning 😁.

  • @G3BRU1K3R5N44M
    @G3BRU1K3R5N44M 2 роки тому

    How do you set the correct MIME type? My file won't load in the browser

    • @AustinCrim
      @AustinCrim  2 роки тому +1

      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.

  • @darthmoomoo
    @darthmoomoo Рік тому

    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).

  • @anuragroy11
    @anuragroy11 2 роки тому

    What VSCode theme are you using?

  • @eduardabramovich1216
    @eduardabramovich1216 Рік тому +1

    Quick question, is it possible to create Desktop Environment, like Gnome, KDE for linux, using WASM?

  • @mmahgoub
    @mmahgoub Рік тому

    TTP -> to the point

  • @riatec6741
    @riatec6741 Рік тому

    pls make fonts mobile friendly

  • @didzc11
    @didzc11 2 роки тому

    Nice tutorial, but now my eyes burn...

  • @chadwick499
    @chadwick499 2 роки тому

    darkmode bro. Youre welcome