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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Contextとはなにか
chiroruxx
1
370
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
Creating Composable Callables in Contemporary C++
rollbear
0
170
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
740
はてなアカウント基盤 State of the Union
cockscomb
0
700
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
150
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
100
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
The NotImplementedError Problem in Ruby
koic
1
930
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
930
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
How GitHub (no longer) Works
holman
316
150k
Fireside Chat
paigeccino
42
4k
The Spectacular Lies of Maps
axbom
PRO
1
820
Discover your Explorer Soul
emna__ayadi
2
1.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
400
Statistics for Hackers
jakevdp
799
230k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
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 ✌