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
a_fujisaki
September 12, 2024
Programming
0
860
rbs-inlineを使ってみた
a_fujisaki
September 12, 2024
Tweet
Share
More Decks by a_fujisaki
See All by a_fujisaki
rails newと同時に型を書く
aki19035vc
6
1.1k
“Rails × 型”での2年間を振り返る
aki19035vc
2
1.1k
Emacs × LSP × Steep
aki19035vc
0
220
MiniMagickの型を生成したい
aki19035vc
0
120
最近追加した型の紹介とその振り返り
aki19035vc
0
700
Other Decks in Programming
See All in Programming
contribution to astral-sh/uv
shunsock
0
540
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
12
7.2k
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
4
15k
CSC509 Lecture 07
javiergs
PRO
0
240
Cursorハンズオン実践!
eltociear
2
1.2k
Six and a half ridiculous things to do with Quarkus
hollycummins
0
210
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
190
理論と実務のギャップを超える
eycjur
0
180
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
420
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
140
Ktorで簡単AIアプリケーション
tsukakei
0
110
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
250
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
8
300
The Cult of Friendly URLs
andyhume
79
6.6k
Automating Front-end Workflow
addyosmani
1371
200k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Build your cross-platform service in a week with App Engine
jlugia
233
18k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.7k
Agile that works and the tools we love
rasmusluckow
331
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
What's in a price? How to price your products and services
michaelherold
246
12k
Code Review Best Practice
trishagee
72
19k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
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もどこかでやり ます