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
rbs-inlineを使ってみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
a_fujisaki
September 12, 2024
Programming
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
rbs-inlineを使ってみた
a_fujisaki
September 12, 2024
More Decks by a_fujisaki
See All by a_fujisaki
自作マクロと型生成
aki19035vc
0
57
rails newと同時に型を書く
aki19035vc
6
1.3k
“Rails × 型”での2年間を振り返る
aki19035vc
2
1.2k
Emacs × LSP × Steep
aki19035vc
0
290
MiniMagickの型を生成したい
aki19035vc
0
160
最近追加した型の紹介とその振り返り
aki19035vc
0
900
Other Decks in Programming
See All in Programming
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
360
Oxlintはいいぞ(続)
yug1224
1
550
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
510
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
210
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
420
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
170
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.3k
Deep dive into the select statement (GopherCon UK)
jespino
0
170
アクセシビリティから考える情報設計
high_g_engineer
0
280
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
680
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
8.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
660
Mobile First: as difficult as doing things right
swwweet
225
10k
How GitHub (no longer) Works
holman
316
150k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
650
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Transcript
rbs-inlineを使ってみた Roppongi.rb#22 <2024-09-12> @aki19035vc
自己紹介 ❏ 藤崎 亮人 (a_fujisaki) ❏ @aki19035vc ❏ イタンジ株式会社 ❏
不動産会社向けのSaaSを提供 ❏ バックエンドエンジニア ❏ ほぼRails・たまにScala ❏ 物件基盤の開発責任者 ❏ Rails × 型 の話が好き ❏ 学生の頃(2016年くらい)からEmacs使ってます
今日話すこと ❏ rbs-inline を使ってみた話 ❏ どんな風に試したか ❏ 実際どうだったか (感想) ❏
良かったところ・気になったところなど ❏ 今後やること ※ rbsとかrbs-inlineとかsteepとかの詳しい解説はしません
rbs-inlineとは ❏ Rubyの型情報をソースコード内にコメントとして直接記述することで、 rbsファイルを別途作成せずに型情報を生成できるツール ❏ 詳しくはリポジトリとかRubyKaigi 2024 のセッションを見てください ❏ https://github.com/soutaro/rbs-inline
❏ https://rubykaigi.org/2024/presentations/soutaro.html
簡単な例
どんな風に試したか ❏ rbs_mini_magickという自作gemの型をrbs-inlineで生成するように変更 ❏ https://github.com/aki19035vc/rbs_mini_magick ❏ 元々はrbsとyardをどちらも書いていたため大変だった ❏ 今回は、全て手作業で rbs-inlineを使う形に書き写した
❏ 使用感とかを確かめるために頑張った ❏ rbsファイルをちゃんと書いていたので、そこからrbs-inlineのコメントを 機械的に付与することも検討はした ❏ yardコメントは全部消した
どうだったか (感想) ❏ コード内に型を直接書けるのは素晴らしい ❏ 今まではコードを書き終えた後、最後にまとめて型を書いてた ❏ rbs-inlineを使うと、コードを書くと同時にrbsを書けて効率が良い ❏ 機能的に足りないものなどは特になかった
❏ wikiに書き方が詳しく載っていたので特に困ることもなかった ❏ https://github.com/soutaro/rbs-inline/wiki/Syntax-guide
悩んでいること・気になること ❏ 書き方 ❏ `@rbs` を基本的に使い、attr_xxx, 定数などは `#:` で書くようにした ❏
yardスタイルの書き方はしない ❏ `#:`で統一しようかは迷っている ❏ 書き方を統一させるためのrubocopがあると嬉しい (rubocop-rbs-inline的な) ❏ rubocopで怒られる部分はひとまず無効化した ❏ rubocopにPRを出してくれる方がいるので、無事取り込まれれば無効化しなくても良くな りそう ❏ コード内に記述したrbsコメントが、生成後のrbsファイルにも含まれている ❏ 特に害はないが、なくても良いのでは?とは思った
今後の話 ❏ 業務で開発しているRailsアプリケーションにrbs-inlineを入れる予定 ❏ 型は(ほぼ)100%書いてある ❏ 人力で書き写すのは現実的ではない ❏ 既存のrbsからrbs-inlineのコメントを機械的に付与するスクリプトを作る予定 ❏
上手くいったら弊社のエンジニアブログで公開するつもり & LTもどこかでやり ます