Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rust Front-end with Yew
Search
Ciro Nunes
September 14, 2022
Programming
89
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust Front-end with Yew
Ciro Nunes
September 14, 2022
More Decks by Ciro Nunes
See All by Ciro Nunes
Type safe CSS with Reason
cironunes
0
150
What I've learned building automated docs for Ansarada's design system
cironunes
0
98
Beyond ng new
cironunes
2
240
Animate your Angular apps
cironunes
0
460
Sweet Angular, good forms never felt so good
cironunes
0
100
Sweet Angular, good forms never felt so good
cironunes
0
320
Progressive Angular apps
cironunes
3
940
Angular: Um framework. Mobile & desktop.
cironunes
1
610
Firebase & Angular
cironunes
0
300
Other Decks in Programming
See All in Programming
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
180
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
180
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.5k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
300
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
JavaDoc 再入門
nagise
1
420
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
Creating Composable Callables in Contemporary C++
rollbear
0
170
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
Designing Experiences People Love
moore
143
24k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
Thoughts on Productivity
jonyablonski
76
5.2k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
430
ラッコキーワード サービス紹介資料
rakko
1
3.7M
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
The Curious Case for Waylosing
cassininazir
1
400
Transcript
Ciro Nunes 14 Sep 22 Rust Front-end with Yew 🦀🇦🇺
Agenda ⁉ What is Yew? Why Wasm & Rust? 🪄
Simple tutorial 🤩 My impressions 🗺 Where to go from here
What is Yew? Why Wasm & 🦀?
What is Yew?
Yew Rust / Wasm client web app framework
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
• Great performance
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
• Great performance • JavaScript interoperability
Why Wasm?
WebAssembly Low-level assembly-like language with a compact binary format that
runs with near-native performance and provides languages like Rust with a compilation target that can run in modern web browsers.
WebAssembly Not a silver bullet for improving performance of web
apps 🤪
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS • Perfect for heavy computation applications
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS • Perfect for heavy computation applications • Multi-threading via Web Workers
Why Rust?
Rust Helps developers write safer code with its rich type
system and ownership model
Simple tutorial
Let’s build a To-do app
None
None
# [ derive(Clone)] struct Todo { text: String, completed: bool,
}
struct TodoComponent { todos: Vec<Todo>, new_todo_txt: String, }
enum Msg { AddTodo, UpdateNewTodo(String), }
impl Component for TodoComponent { type Message = Msg; type
Properties = (); fn create(_ctx: &Context<Self>) - > Self {} fn update(&mut self,_ctx, msg: Self : : Message) - > bool {} fn view(&self, ctx: &Context<Self>) - > Html {} }
fn create(_ctx: &Context<Self>) - > Self { Self { todos:
vec![Todo { text: "Learn Rust".to_string(), completed: true, }], new_todo_txt: "".to_string(), } }
fn view(&self, ctx: &Context<Self>) - > Html { let link
= ctx.link(); let on_cautious_change = link.batch_callback(|e: Event| { let input = e.target_dyn_into: : < HtmlInputElement>(); input.map(|input| Msg : : UpdateNewTodo(input.value())) }); html! { <div> <ol> { self.todos.iter().map(|todo| html! { <li> <input type="checkbox" checked={todo.completed} / > <span>{format!("{}", todo.text)} < / span> < / li> }).collect: : < Html>()} < / ol> <div> <input type="text" value={self.new_todo_txt.to_string()} onchange={on_cautious_change} / > <button onclick={link.callback(|_| Msg : : AddTodo)}>{ "Add" } < / button> < / div> < / div> } }
fn update(&mut self, _ctx: &Context<Self>, msg: Self : : Message)
- > bool { match msg { Msg : : AddTodo = > { let new_todo = Todo { text: self.new_todo_txt.to_string(), completed: false, }; self.new_todo_txt = "".to_string(); self.todos.push(new_todo); true } Msg : : UpdateNewTodo(new_txt) = > { self.new_todo_txt = new_txt; true } } }
use yew : : prelude : : *; fn main()
{ yew : : start_app: : < TodoComponent>(); }
My impressions
My impressions Yew
My impressions Yew • Very similar to React, but it’s
Rust
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics • Good documentation
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics • Good documentation • Looks promising
Where to go from here
Where to go from here Yew
Where to go from here Yew • Check out the
docs yew.rs
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router • Checkout stylist for CSS-in-Rust
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router • Checkout stylist for CSS-in-Rust • Take advantage of Rust parallelism in Wasm for heavy computations
Thanks for listening ✌