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
96
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
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.3k
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
140
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
820
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
ふつうのFeature Flag実践入門
irof
7
4k
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
6.7k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
6
1.3k
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
5.5k
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Prompt Engineering for Job Search
mfonobong
0
350
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
430
Raft: Consensus for Rubyists
vanstee
141
7.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Ethics towards AI in product and experience design
skipperchong
2
310
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Statistics for Hackers
jakevdp
799
230k
Skip the Path - Find Your Career Trail
mkilby
1
150
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 ✌