Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
#DeStudy #01 Rust入門
Search
K.Mori
July 31, 2020
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
#DeStudy #01 Rust入門
#DeStudy #01のRust入門スライドです。
K.Mori
July 31, 2020
More Decks by K.Mori
See All by K.Mori
GraphQL入門
morikyon
1
120
Other Decks in Programming
See All in Programming
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.6k
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
380
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
430
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
220
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
The Rails Doctrine Decade
koic
2
590
Railsバージョンを4倍にした話
optim
0
370
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
460
Next.js: The final boss of Web Performance
guaca
0
260
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
310
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
590
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Between Models and Reality
mayunak
4
500
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Transcript
もちろん俺らは抵抗するで︖ Rustで kmori (@forestython)
今⽇のテーマ 2
3 Rust
Rust • Firefox の Mozilla がつくった新しいプログラミング⾔語 • 2010年7⽉7⽇に登場 • Stack
Overflowの最も愛されているプログラミング⾔語の 2016年から2019年まで4年連続1位︕ • 以下のソフト / サービスはRustで実装 • Firefox • Dropbox • AWS Lambda (Firecracker) • Discord 4
Rustのいいところ • メリット • くっそはやい • メモリ管理が優秀である • NULL安全と型推論が存在する •
デメリット • 学習コストが半端じゃない 5
実⾏速度 • 私のダメダメな実装よりQiitaの記事⾒たほうが有益なので引⽤ ü https://qiita.com/reki2000/items/55ef54b96b2 6d80ad694 • ダイクストラ法での探索アルゴリズム(枝数30万程度) ü C++
≒ Rust > Go > Julia > Kotlin > Cython > JavaScript > Python • ちなみに私のダメダメ実装でもエラトステネスの篩(指定数以下の 素数をすべて抽出)で⽐較したところ、C++とRustは拮抗してい て、Juliaがその2倍程度、Pythonが10倍程度でした 6
メモリ管理 • メモリ管理⽅法 1. プログラマが気合で管理 (C, C++) → 開放し忘れによるメモリリークの危険性 2.
システムが⾃動で不要なメモリを集約 (GC) → 実⾏時のオーバーヘッド発⽣ • Rustの管理⽅法 ü 値の所有者(=値を格納する変数)がスコープ(=簡単 に⾔うと値を含む関数等)から出た時点で開放 ü 気合で管理してた際の⼀時的な確保/開放が実現可能かつ、 GCのようなオーバヘッドとよしなにしてくれる部分をもつ 7
NULL安全、型推論 • NULL安全 • nullに対するメソッドのコール等をしたら実⾏時に出るエラー String str = null; str.length();
// => java.lang.NullPoinerException を回避するために、コンパイル時にエラーを出すこと • 鬱陶しいnull pointer exception をテスト時に発⾒ もしくは バグのまま納品せずに済む • 型推論 • 簡単に⾔うと型を推測してくれる let num; // => この時点で num は i32型と宣⾔していない num = 100; // => がしかし100の代⼊によって⾃動で定義 8
• サンプル︓ただのFizzBuzz • https://doc.rust-jp.rs/rust-by-example-ja/fn.html • よくある感想 • 正直、型が多すぎてわからん︕ • 関数の引数でも型指定しすぎててわからん︕
• 関数の定義の順番がしていないのでパッと⾒参照関係がわからん︕ 学習コスト 9
タイトル: とりまいれてみよう 10
• Mac $ brew install rust • Ubuntu $ sudo
apt install rustc • Windows スタートボタン → Ubuntu → $sudo apt install rustc ※ Windowsを素のままで使ってコーディングは 正気の沙汰ではない(諸説あり) How to install 11