Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Rewriting My React Website in WebAssembly

Автор: Jeff No Zhao

Загружено: 2020-10-13

Просмотров: 29577

Описание:

Hey guys, welcome back to another video.

Today I want to share with you one more way of building a website. And that is, building a website using Rust and WebAssembly. More specifically, I'll be showing how I rewrote my old personal website using Rust and WebAssembly.

React website source code: https://github.com/kamiyaa/website-react
Wasm website source code: https://github.com/kamiyaa/website-wasm

Find me elsewhere:
Instagram:   / jeff.no.zhao  
Github: https://github.com/kamiyaa

Books I've been reading:
The Lean Startup by Eric Ries: https://amzn.to/3hwbg3J
Late Bloomers by Rich Karlgaard: https://amzn.to/2DcmCLo
Disclaimer, these are affiliate links. If you make a purchase, I will receive a commission.

I initially wrote my website in React because I wanted to learn react at the time. But ever since learning React, I've also been exploring alternatives to it
like Svelte and WebAssembly. Not because I don't like React, but I think its nice to see what other tools are available.
When I tried Svelte, I couldn't get html bookmarks to work properly with their
routing system. So I ended up not using it for my website. But this time with WebAssembly, I actually got something working that I'm genuinely happy with. And it'll be replacing my old react website moving forward.

I used a Rust library called Yew (https://yew.rs). Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly. What you'll find is that its very similar to React's component system. It features jsx-like syntax, has a virtual DOM and is interoperable with Javascript

It took me about 4-5 days to finish the website. It was a pretty close 1-to-1 mapping between the React version and WebAssembly version; I basically reused all my component logic. Since its a personal website, most of the content is static
The only problem I ran into was how arrays work in Javascript and Rust.
In Javascript, global arrays can be mutable. So I had an array of projects. And whenever I fetch the github metrics for it, I would add those metrics to that projects attributes so I don't need to re-fetch them later. This is to reduce the amount of API calls my website makes because Github has a limit on their APIs. In Rust, global arrays are static, meaning they're immutable. So I couldn't apply the same technique. So I ended up creating a global hashmap that mapped the `username/repoman` to their github metrics.

My thoughts on Yew.rs is that the project is progressing very well. It does have minor quirks where class attributes are inconsistent or their fetching APIs are hard to use. I wish they would follow React hooks more in the future.

There are disadvantages to using WebAssembly though.
1. There is much more boilerplate code to write
2. The language is statically-typed and not garbage collected so its much less forgiving than a language like Javascript that is garbage collected and dynamically typed.
3. Only recent releases of the major web browsers support WebAssembly. So most legacy systems won't even be able to access your website.
4. Ecosystem around WebAssembly is still lacking in terms of features and documentation, compared to the node/react ecosystem.

There are also advantages to using WebAssembly as well:
1. This technology will be much more used in the future, so learning it now could be beneficial
2. Performance benefits. My new website is about half the size as my react website.
3. Cool factor :)

So, do I recommend writing your website in WebAssembly?
Probably not for the entire website like what I did. There's just too much boilerplate
code to write to get anything substantial working. At least for the Yew library. You have to explicitly state all the messages and props that can be passed to a specific component. The tooling for it is still not as feature rich as node/react. But if you want to use WebAssembly for a small portion of your website to speed things up, or you're building a big Single-Page Application like Google Maps or Google Docs where you want more performance, then you might want to look into WebAssembly.

Music:
Imagine by lukrembo
Michikusa by PeriTune (Licensed under https://creativecommons.org/licenses/...)

Timestamps:
00:00 Intro
01:43 Website Demo
02:52 What I used
04:11 Code examples
07:07 Thoughts on tools
08:00 Advantages/Disadvantages of Wasm
09:20 Should You Use Wasm For Your Next Website (Conclusion)

Rewriting My React Website in WebAssembly

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

5 Problems I Have with Golang

5 Problems I Have with Golang

AssemblyScript: простота использования WebAssembly

AssemblyScript: простота использования WebAssembly

Kevin Hoffman — Building a Containerless Future with WebAssembly

Kevin Hoffman — Building a Containerless Future with WebAssembly

Understanding React's UI Rendering Process

Understanding React's UI Rendering Process

An introduction to WebAssembly

An introduction to WebAssembly

Введение в WebAssembly — начало работы с Wasm

Введение в WebAssembly — начало работы с Wasm

Bringing WebAssembly outside the web with WASI by Lin Clark

Bringing WebAssembly outside the web with WASI by Lin Clark

WebAssembly (WASM) vs. Docker - Our Expert Analysis

WebAssembly (WASM) vs. Docker - Our Expert Analysis

Учебник по React для начинающих

Учебник по React для начинающих

Kubernetes — Простым Языком на Понятном Примере

Kubernetes — Простым Языком на Понятном Примере

Операции CRUD веб-API ASP.NET — учебное пособие по .NET8 и Entity Framework Core

Операции CRUD веб-API ASP.NET — учебное пособие по .NET8 и Entity Framework Core

Почему этот сайт такой быстрый!?

Почему этот сайт такой быстрый!?

Getting Started with WebAssembly (WASM) with Rust Lang

Getting Started with WebAssembly (WASM) with Rust Lang

G-46. Disjoint Set | Union by Rank | Union by Size | Path Compression

G-46. Disjoint Set | Union by Rank | Union by Size | Path Compression

Rust 3D Graphics in the Browser: Boilerplate Setup and WASM Introduction

Rust 3D Graphics in the Browser: Boilerplate Setup and WASM Introduction

WHY WEBASSEMBLY IS IMPORTANT | USE CASES | Introduction to WebAssembly (WASM)

WHY WEBASSEMBLY IS IMPORTANT | USE CASES | Introduction to WebAssembly (WASM)

Введение в целевую веб-сборку (WASM) с помощью Golang

Введение в целевую веб-сборку (WASM) с помощью Golang

Собеседование по React | Фронтенд-разработчик | Вопросы по React для 5–8-летних, 2023 г. #reactjs

Собеседование по React | Фронтенд-разработчик | Вопросы по React для 5–8-летних, 2023 г. #reactjs

CSS анимации уровня кино: Как делать сцены без JavaScript?

CSS анимации уровня кино: Как делать сцены без JavaScript?

Создание Rust-фронтенда (действительно БЫСТРЫЕ веб-приложения с Yew)

Создание Rust-фронтенда (действительно БЫСТРЫЕ веб-приложения с Yew)

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]