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
talk about IO
Search
usa
November 08, 2015
Programming
2k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
talk about IO
大江戸Ruby会議05 基調講演「あいおーのはなし」
usa
November 08, 2015
More Decks by usa
See All by usa
Rubyの安定版を保守する意義 / Why we maintain stable versions of Ruby?
unak
0
180
WindowsにおけるRubyのエンコーディングの話 Ruby3版/Ruby's encoding on Windows at Ruby3
unak
0
470
PIXIV TECH FES. short session / What kind of contribution to OSS is really pleased?
unak
0
2.2k
Internal of the image processing required on the developing of web applications
unak
6
5.4k
Schrödinger's branch, or Ruby is dead every year
unak
0
780
Other Decks in Programming
See All in Programming
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
150
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
180
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.1k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
140
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
210
The NotImplementedError Problem in Ruby
koic
1
840
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
550
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.3k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
350
スマートグラスで並列バイブコーディング
hyshu
0
160
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
230
sira's awesome portfolio website redesign presentation
elsirapls
0
280
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
200
Navigating Team Friction
lara
192
16k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
Art, The Web, and Tiny UX
lynnandtonic
304
22k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
170
Transcript
西暦2015年 時に、
自 己 紹介 、
なかむら(う) CRuby Committer Windows版メンテナ 安定版(2.1,2.0.0)メンテナ
なかむら(う) CRuby Committer usa @unak
None
基調講演
あいおーの は な し
None
https:/staff.aist.go.jp/tanaka- akira/pub/stdio-considered-harmful-lc2005- paper.pdf
None
Ruby 1.8までのI/O → C stdioベース fopen, fread, fwrite, etc… ファイルポインタ
FILE *
Ruby 1.8までのI/O → C stdioベース Ruby 1.9以降のI/O →POSIX I/Oベース
Ruby 1.8までのI/O → C stdioベース Ruby 1.9以降のI/O →POSIX I/Oベース open,
read, write, etc… ファイルディスクリプタ int
1. スレッドのread待ち 2. errnoをクリアするstdio実装 3. ungetc 4. 双方向ストリーム 5. 読み込み・書き込みの切替え
6. nonblocking writeにおけるデータ消失 7. nonblocking IO#readの動作 8. readpartialの提案・実装 9. Solarisの256個制限 10.EOFフラグ
Ruby m17n I/Oに関しては: • ファイルオープン時のエンコーディング 指定 • 入力データへのエンコーディング情報の 付与 •
必要時の入出力データのエンコーディン グ自動変換
現在のRuby I/Oのまとめ OS (POSIX I/O) Ruby class IO IO#read IO#write
… transcode エンコーディング変換 各Ruby Script おまえら \ (^o^)/
本当に?
OS (POSIX I/O) Portableだと 思い込んでいた? いつから
Rubyの 暗黒面へ ようこそ
W i n d o w s という O Sがあってな
OS (POSIX I/O) Ruby class IO IO#read IO#write … transcode
エンコーディング変換 各Ruby Script おまえら \ (^o^)/ モドキ OS (Win32 API)
Rubyインタプリタが期待する POSIX I/O #とは 全てのI/Oがファイルディスクリプタで 抽象化されていて 大抵のAPI(システムコール)はどのI/O でも共通に利用できて どのプラットフォームでもほぼ確実に 同じコードで利用できる
Windowsにおける POSIX I/Oモドキの場合 socketは完全に別扱いになっていて 対象外 ファイルはともかく、パイプや コンソールだと挙動不審な面がある 必要な関数がいくつも欠けていて 実用上問題がある
そもそも Windowsに POSIX I/Oを 期待する方が おかしい
RubyのI/O が 間違っている
OS (POSIX I/O) Ruby class IO IO#read IO#write … transcode
エンコーディング変換 各Ruby Script おまえら \ (^o^)/ モドキ OS (Win32 API) 独自実装で代替
やってられ る か !
usaは激怒した。 必ず、かの邪智暴虐の RubyのI/Oを 正さねばならぬと 決意した。
ぼくのかんがえた さいきょうの あいおー じっそうあん
PerlのI/O実装 Perl functions read,write,… PerlIO API PerlIO_read,PerlIO_write,… PerlIO_funcs PerlIOUnix_read,PerlIOUnix_write,… OS
(POSIX I/O)
PerlのI/O実装 Perl functions read,write,… PerlIO API PerlIO_read,PerlIO_write,… PerlIO_funcs PerlIOWin32_read,PerlIOWin32_write,… OS
(Win32 API)
PerlIO は すばらしい
パクろう
提案 RubyIO(仮称)の導入 io.c内で直接OSやCライブラリのI/O関数を 呼ぶのをやめ、RubyIO APIを呼ぶ。 各IOオブジェクトが、そのI/O種別に応じた プリミティブ関数セットを保持できるように。 テキストモードはRubyIOの階層の一つとして この仕組みの中で実装を用意。
テキストモード 問 題 ネイティブスレッドが導入されたとき、 別スレッドのI/Oをキャンセルさせる必要が あることから、read関数を新規に再実装。 テキストモードの実装がツラかったので、 m17nの変換機能を利用して、改行文字の 変換を行うようにした。 「遅い」という理由で総スカンを食らい、
結局、テキストモード時はPOSIX I/Oモドキのreadを 呼ぶように……
提案するだけなら 猿 でもできる
実装して ナンボ
なので、 実装してみた かったけど 間に合わず
目標 次(2.3)の次のRuby(2.4? 3.0?)への 導入を目指す 2016年前半中にはtrunkに入れたい 鋭意実装中(やる気が続くとは 言ってない)
ぼ く は よ う や く の ぼ り
は じ め た ば か り だ か ら な こ の は て し な く 遠 い Ruby I/O 坂 を よ …
ありがとう
今度こそ本当に