Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Irb 20th anniversary memorial session: Reish and Irb2!?

Irb 20th anniversary memorial session: Reish and Irb2!?

rb has been born 20 years now.. To commemorate it I will talk about Reish and the next generation of Irb. Reish is an an unix shell for rubyist. It is a shell language that realize Ruby's feature. Also, it is an language which is metamorphosed from Ruby for more natural shell operation. Reish is under development. Reish is similar to Irb in usage, and various knowledge was gained in its development. I will introduce the vision of Irb next generation based on that.

Irbは今年で生まれて20年になります. それを記念してReishとIrbの次世代の話をします. ReishはRubyistのためのshellで, Rubyの機能を実現しています. また, Ruby操作から自然にshell操作に変換可能な言語です. Reishは現在開発中です. ReishはIrbと使い方が似ていて, その開発からいろいろな知見を得ることができます。それを基にIrbの次世代の構想をお話しします.

Keiju Ishitsuka

September 22, 2017
Tweet

More Decks by Keiju Ishitsuka

Other Decks in Technology

Transcript

  1. Irb 20th anniversary memorial session # #2 2 RubyKaigi2017 •

    石塚圭樹 Keiju Ishitsuka • Rubyの名付け親 Ruby's godfather • Irbの作者 Irb's author 自己紹介 Self-introduction
  2. Irb 20th anniversary memorial session # #3 3 RubyKaigi2017 自己紹介

    - 現在 Self-introduction - current situation • ペンタ アドバンスト ラボラトリーズ において Work at Penta Advanced Lab. – OO系システムの研究開発(Rubyを含む) – OO関連技術の導入コンサルティング – などなど Research, Development and Consultant about Ob ject-Oriented system...etc
  3. Irb 20th anniversary memorial session # #4 4 RubyKaigi2017 はじめに

    Introduction • 今年は Irb が誕生して20年 This year marks the 20th anniversary of Irb – 今年の 大江戸Ruby会議06 『Ruby考古学II 1993-1997』 で、今年は Irb の誕生20周年だ とお話ししました。 I have taked about this in “Ruby Archeolog y II 1993-1997” at The Greater Edo Ruby C onference 06
  4. Irb 20th anniversary memorial session # #5 5 RubyKaigi2017 はじめに(続)

    Introduction(cont.) • ということで、Irbの誕生20周年を記念して  Celebrating this, I will talk about – Irbの歴史的意義  Historical significance of Irb – Irbと関連の深いReish  Reish, which has deep connection with Irb – Irbのこれから  Future of Irb について話をします • Special thanks to Sawada Tsuyosh by Engl ish translation.
  5. Irb 20th anniversary memorial session # #6 6 RubyKaigi2017 Ruby考古学

    - 復習 RubyArchaeology - Review • 20年前、1996-1997には、Rubyにいろ いろなことがありました 20 years ago, in 1996-1997, Ruby underwent many events – 『Ruby考古学II 1993-1997』より (Recap from "Ruby Archeology II 1993- 1997")
  6. Irb 20th anniversary memorial session # #7 7 RubyKaigi2017 Ruby考古学

    - 復習(続) RubyArchaeology – Review(cont.) • 1996/12/16 Ruby本企画開始 Start a development of The Ruby Book • 1996/12/25 Ruby 1.0 リリース!! Release of Ruby 1.0 • 1997/09/13 最初のRubyセミナー First Seminar on Ruby • 1997/09/30 Irb(rbc)公開 Release of Irb (rbc)
  7. Irb 20th anniversary memorial session # #8 8 RubyKaigi2017 Ruby考古学

    - 番外編 RubyArchaeology - Extra story • 1997/08/21 この辺りから開発開始か? Start of the development of Irb (rbc) (perhaps) – 現存する最古の Irb(rbc)コードが存在 Oldest remaining code dates to this day • 1997/09/02 字句解析器導入 Introduction of a lexical analyzer • 1997/09/30 Irb(rbc)公開 Release of Irb (rbc) • 1997/10/01 Rubyの標準配布になる Became part of standard Ruby installation • 1998/04/10 Irbに正式改名 Formmaly renamed to Irb
  8. Irb 20th anniversary memorial session # #9 9 RubyKaigi2017 Irb

    - 開発のきっかけ Irb - Motivation of development • bc – 最初、Irbの名前は rbc だった。 Originally called rbc – bcは、UNIXの由緒あるCUIベースの計算機 bc stands for Unix's historical CUI-based calculator • perl -de 0 – perlデバッガを(デバッグ対象となるスクリプトファイ ルなしで)起動 Start perl debugger (without a script file) – perlの関数の振る舞いをチェックできる Can check the behaviour of perl functions • sample/eval.rb
  9. Irb 20th anniversary memorial session # #10 10 RubyKaigi2017 Irb

    - 歴史的意義 Irb - Historical significance • REPL(Read-Eval-Print-Loop) – REPLとは、Lispの REPL stands for Lisp's ... • (loop (print (eval (read)))) から • The First REPL – 当時、複雑な構文を持つ言語のREPLは、ほとんど存在 しなかった。 Few languages with complicated syntax had a REPL in t hose days – Irbの登場以降、Ruby以外の他の言語でもREPLが開発 されるようになった。 Since Irb, REPL for languages other than Ruby started to emerge Ruby的には: loop{p eval gets}
  10. Irb 20th anniversary memorial session # #11 11 RubyKaigi2017 Irb

    - 用途 Irb - Usage • REPL Deriven development – Rubyの振る舞いを確かめるため Confirm the Ruby's behaviour – ライブラリ等のデバッグ用コンソール Console for debugging libraries and its k ins – 学習用にも使える Educational purpose • とはいえ、Irb上で生活している人はい ないと思う Nevertheless, I don't think anyone li ves on Irb
  11. Irb 20th anniversary memorial session # #12 12 RubyKaigi2017 Reish

    - なぜ、RubyistのためのShellか? - Why do we need Shell for Rubyists? • Reishの目的 Purpose of Reish – Shellの上でもRuby的な生活を満喫するため To enjoy a Ruby-ish life on a shell • Enumerable • Iterator • Object-Oriented • Other Ruby's feature
  12. Irb 20th anniversary memorial session # #13 13 RubyKaigi2017 Reishの文法

    Syntax of Reish • 基本はShell文法/Basically, shell syntax – Command-base – Pipeline – Job control • Ruby的文法/Rubyistic syntax – Control structure – Block/Iterator – Method definition • その他/Others – Group
  13. Irb 20th anniversary memorial session # #14 14 RubyKaigi2017 Reishの文法

    - 基本文法 Syntax of Reish - Basic Syntax • 基本的にはShell Basically, shell syntax – comma-less, string-base – command arg1 arg2 ... – command1 | command2 ... – command1; command2; ... & – command > /tmp/foo ...
  14. Irb 20th anniversary memorial session # #15 15 RubyKaigi2017 Reishの文法

    - コマンド引数 Syntax of Reish - Command Argument • 引数は評価されない/Arguments are not evaluated – 基本は文字列/ Basically, strings • variable reference – $local_var, $$gloval_var, $@inst_var, $@@class_var • literal – array : %[e1 e2 ...] – hash: %{k1 => v1 k2 => v2...} – 正規表現(regular exp): %/.../ • group, backquote – (command_1; command_2; ...; command_n) – `command_1; command_2; ...; command_n` • RubyExp – $(...ruby_codes...)
  15. Irb 20th anniversary memorial session # #16 16 RubyKaigi2017 Reishの実行

    Execution of Reish • Reishのコードは, Rubyに変換されて実行される Reish code is converted into Ruby, and is then executed • commandは実際にはメソッド A command is actually a method – Reish的には、Rubyのメソッドはビルトインコマンドとして扱われる Internally, Reish handles Ruby methods as built-in command s • パイプラインは(.)に変換される Pipeline is converted into (.) – command1 | command2 => command1.command2 – ex • ls | grep %/.../ => ls().grep(/../)
  16. Irb 20th anniversary memorial session # #17 17 RubyKaigi2017 Reishの文法

    - 制御コマンド Syntax of Reish - Control Command • begin command – begin ... rescue ... else ... ensure ... end • if command – if cond-exp [;then|\n] ... else ... end • while command – while cond_exp [;do|\n] sequence end • Other control command – for, case/when, unless, break, next, redo, r etry, raise, return, yield • modifier command – if-modifire、unless-modifire, while-modifire, until-modifire, rescue-modifire
  17. Irb 20th anniversary memorial session # #18 18 RubyKaigi2017 Reishの文法

    - Block Syntax of Reish - Block • command arg1 ... argn {|v1 ...| ....} • command arg1 ... argn --do ... end – ex) • ls -l | collect {|e| $e.chomp} • ls -l --do |l| puts $l; end
  18. Irb 20th anniversary memorial session # #19 19 RubyKaigi2017 Reish

    - Job Control • Job – 実行単位(Execution Unit)がjobになる An execution unit becomes a job – Ruby的には、job毎にthreadを起動している Internally, Ruby starts a thread per job • foreground jobとbackground job – コマンド実行中に^Z Press ^Z during command execution – または, 下記で実行する/ Or, as follows • command & – fg/bg command – kill command
  19. Irb 20th anniversary memorial session # #20 20 RubyKaigi2017 Reish

    - Completion • bash/zsh風のcompletion機能を実現 bash/zsh-like complementation • command/method名補完 Command/method name complementation • さらに、command-spec/method-specを定 義することにより、引数(オプション)の補完 も可能 Can also complement optional arguments b y configuring command-spec/method-spec
  20. Irb 20th anniversary memorial session # #21 21 RubyKaigi2017 Reish

    - Smart Completion • Reishはパーザを持っている Reish has a parser – メソッドチェーンを識別できる Can recognize method chains • MethodSpec – 所属、戻値、引数のクラスを指定できる Can configure the class of the owner, return value, and arguments – メソッドチェーンのメソッドの所属を識別し補完の絞り 込みが可能 • Can narrow down the complementation by recognizing the owner of a method within a chain
  21. Irb 20th anniversary memorial session # #22 22 RubyKaigi2017 Irb再考

    - 最近のIrb周辺の状況 Irb review - Recent situation around I rb • Irbの開発は長いこと停止している Development of Irb has been stalled for long • 知らぬまに似たアプリケーションが出てきている Similar applications have emerged – Pry, ... • Reishの開発の進行/Progress of Reish – いろいろ見えてきた Some directions became evident • ということで、ちょっと頑張らないといけないなぁと思って いるところ。 As such, I am starting to feel I have to work hard o n it
  22. Irb 20th anniversary memorial session # #23 23 RubyKaigi2017 Irb再考

    - Irbの現状分析 Irb review - Current status analysis o f Irb • lexical analyser – トークンが分かる/Recognizes tokens • Irb以外にこれを利用したアプリがいくつか存在 Used by some apps other than Irb • Irbとしては、特に利用していない Irb does not particularly make use of it – 限界もある/Has limits • パーザを持っていないので、完全ではない。 Lacking a parser, it is not perfect • いろいろなアドインツールが存在 Has some add-in tools – いまさら、大幅な修正は不可能でしょう!? Not practical to make a major modification at this ti me
  23. Irb 20th anniversary memorial session # #24 24 RubyKaigi2017 Reish再考

    Reish Review • Reishは完全なパーザを持っている Reish has a full-fledged parser – それを利用し、高機能なことが実現できている Capable of higher-level functionalities • ReishってRubyに似ていないか? Doesn't Reish resemble Ruby? – Reishにrubyのパーザを持たすことはできないか? Can't we equip Reish with a Ruby parser? – そうすれば、いろいろできることが増えそう... Then, we can do more things • Irb2 == Reish上のIrb == Reirb
  24. Irb 20th anniversary memorial session # #25 25 RubyKaigi2017 Irb2

    = Reirb - Feature というか 思い - Future rather request • REPL機能を充実したい Rich REPL functionalities • 特に、入力時にいろいろできないか? Particularly, several things during input – navigation • completion • Zsh-like help • variable inspection – editing function • 入力中のスクリプトをもうちょっと編集しやすくしたい Make input script more editable • debugに関しても何か.../ On debugging – 普通のデバッガではなく… A non-ordinary debugger
  25. Irb 20th anniversary memorial session # #26 26 RubyKaigi2017 Reish

    - Reidline • Reidline - Reish用のマルチラインエディタ Multi-line editor for Reish - 現在開発中 Currently under development
  26. Irb 20th anniversary memorial session # #27 27 RubyKaigi2017 今後の予定

    Future plan • Reish – まずは、Reishでもっていろいろ試したい First of all, I'd like to try various with Reish • Irb2 = Reirb – まあ、ボチボチと... Well, little by little. f