で変態度を競い合うプログラミングの祭典 cf. International Obfuscated C Code Contest (IOCCC) • This talk dishonors the winners of TRICK 2013 本発表では TRICK 2013 入賞者の不名誉を讃え • And demonstrates the winning entries さらに入賞作品のデモを紹介します
Transcendental /ˌtransɛnˈdɛnt(ə)l/ – “relating to a spiritual realm” 「霊界に関する」 – but it is translated as “unworldly technical” in Japanese なぜか日本語では「超絶技巧」と訳される • ex. Transcendental Etudes (超絶技巧練習曲、Liszt) • Imbroglio /ɪmˈbrəʊlɪəʊ/ – “an extremely confused, complicated, or embarrassing situation” 極めて混乱した、複雑で、厄介な事態 adapted from Oxford Dictionaries Online Named by leonid
Ruby program 現世利益のない、意味不明な Ruby プログラムを書く • Illustrate some of the subtleties (and design issues) of Ruby Ruby のある種の神秘性 (と仕様バグ) を明らかにする • Show the robustness and portability of Ruby interpreters Ruby 処理系の意外な堅牢性と移植性を示す • Stabilize the spec of Ruby by the presence of valuable but unmaintainable code メンテナンス不能だが価値あるコードを世に放つことで Ruby の仕様を 安定化する
complete Ruby program. あなたの作品は単体で動作する Ruby プログラムでなければならない。 2. The size of your program must be <= 4096 bytes in length. The number of non-space characters must be <= 2048. The total size of your compressed submission must be less than ten megabyte in size. あなたのプログラムのサイズは 4096 バイト以下でなければならない。非 空白文字の数は 2048 以下でなければならない。あなたの投稿は zip 全体で 10 MB 未満でなければならない。 3. You can submit multiple entries, and your team may consist of any number of members. あなたは何作でも作品を投稿できる、また、あなたのチームは何人で あっても良い。
must be submitted under MIT License. あなたの作品全体は MIT ライセンスで投稿されなければならない。 5. Your entry must bring the judges a surprise, excitement, and/or laughter. あなたの作品は審査員に驚き、感動、(and/or)笑いを与えなければなら ない。 • Meta Rule: Rule Golf – Too many restrictions may inhibit creativity あれこれ制約して作品の可能性を絞らないように
is recommended. MRI 1.9/2.0 で動くことを推奨 • MRI 1.8 is highly discouraged because your entry won't work in near future. 1.8 でしか動かないコードは強く非推奨 • You can use implementations other than MRI, such as JRuby and Rubinius. MRI 以外の実装もOK
gem 使って OK • But note that we will expect such entries to be much more interesting than an entry that uses no library; hence we will judge them strictly. ただしその分面白い作品であることが期待され、審査基準は厳しくなる • It is highly discouraged to abuse gem to get around the size limit. サイズ制限を回避するために gem を使うのは強く非推奨
more portable, and/or more funny entries. ストイックで、様々な環境で動き、笑いのある作品が評価されやすい • You are encouraged to examine the winners of previous IOCCC contests. 過去の IOCCC の勝者を研究することを推奨する • To judge without bias, we will try to keep each entry anonymous during judgment. Do not include anything that reveal your identity (such as a signature, copyright, URL, etc.) in your program. 偏見なく審査できるよう、審査の間はすべての作品を匿名として扱うので、 プログラムに作者がわかるような情報を含めないこと
matz • leonid • eban – IOCCC winner – Advocate for Transcendental programming. – Media Artist. – Chairman at NicoNicoGakkai Beta. – The admin of anarchy golf. – IOCCC winner. – The author of Japanese esolang book. – The creator of Ruby. – The 1st super Ruby golfer in the anarchy golf. – Ruby committer. – The 2nd super Ruby golfer in the anarchy golf.
point scale 各審査員は各作品を 10 点満点で評価 – Each entry gains the average 平均点がスコア • A judge has no right to score his own entry 自分の作品は審査対象外 • Judges keep each entry anonymous during judgment 審査員は作者を知らずに審査する
Four” for particularly high dishonors 上位4作品は特に不名誉を受ける • Winning entries will be pushed automatically 入賞作品は時間になったら push されます http://github.com/tric /trick2013/ Dishonorable mention No k!
trick: method_missing • Eye-catching feature: Character status ---------------------------------------- character status ---------------------------------------- Alice : tired line:5 Alice : hear line:14 Alice : feet line:19 Alice : pop_down line:21 WhiteRabbit : ran line:12 WhiteRabbit : say line:15
trick: aliasing • Extra tricks: – A method name “ruby” and variable name “ruby” coexist – Dynamic typing hell alias RUBY inject; alias _Ruby join; end class Fixnum; alias ruby chr; end class Symbol; alias ruby to_s; end class String; alias ruby chars; end class Enumerator; alias ruby with_index; end class Class; alias ruby new; end alias ruby puts
of ObjectSpace.each_object • By exploiting this infinite loop, a brainfuck interpreter is constructed この無限ループを利用して brainfuck 評価器を構成している • Extra trick: history option obj yield! object space obj obj new obj new obj yield! yield! yield! yield! new obj
feature at all 実行可能なだけ、一切の機能なし Is the most Transcendental, Imbroglio Ruby program 現世利益のない、意味不明な Ruby プログラムである • Exploits the fact that a method does not check if it accepts block argument or not メソッドがブロック引数を受け付けるかどうかをチェックしないことを悪用 • Reveals a spec-level bug: missing is_an? is_an? がないという仕様バグを浮き彫りに Shows some of the subtleties (and design issues) of Ruby Ruby のある種の神秘性(と仕様バグ) を明らかにしている
all Ruby implementations ほぼすべてのRuby実装で実行可能 shows the robustness and portability of Ruby interpreters Ruby 処理系の意外な堅牢性と移植性を示している • This code returns true $ruby.is_a?(Object){|oriented| language}
on Elo rating • Main trick: Elo rating – A way of calculating the relative skill levels of players • Used in chess, shogi, etc. – Each program represents its own rate • Sub tricks: cheat OCR, abuse of -i $ ruby alice.rb bob.rb == alice.rb beats bob.rb $ ruby bob.rb ailce.rb == bob.rb beats alice.rb
up characters from constant names _ { return } LocalJumpError _ { method(:p).unbind } UnboundMethod _ { eval “{ “ } SyntaxError _ { Thread.current.join } ThreadError • Extra tricks – Another U is picked from RUBY_COPYRIGHT – JRuby fails to run this program
piano roll DSL – # is a note, and | is a slur • Extra tricks: – “eval-split-join” idiom is not used – Frequency modulation synthesis FM 音源合成 • Judges’ comments – boring 食傷気味
able to write a program unless for you, program in ruby language is too difficult. At the end of your journey towards the ultimate program; you must be a part of a programming language. You will end if you != program
structure is begin … end if false – for statement is used for defining variables begin ... ... unless for you, program in ... ... end ... end if you != program begin with an easy program. you should be able to write a program unless for you, program in ruby language is too difficult. At the end of your journey towards the ultimate program; you must be a part of a programming language. You will end if you != program
0x20 ' ' to 0x7e '~' exactly once. • The program contains each ASCII character from 0x20 ' ' to 0x7e '~' exactly once. !@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[% r{¥"}mosx,4>6]|?'while(putc 3_0-~$.+=9/ 2^5;)<18*7and:`#
x } – But cannot “declare and then use” variables • Features – $. global variable, the best friend of Ruby golfers – Trash box of unused alphabets: THE QUICK BROWN … – Quote characters – Century puzzle-ish !@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[% r{¥"}mosx,4>6]|?'while(putc 3_0-~$.+=9/ 2^5;)<18*7and:`#
Top three entries will be included in the Ruby official repository as “sample” programs 上位3作品はRuby公式リポジトリにコミットされます – The next Ruby tarball will be released with them 次期 Ruby パッケージにも含まれた状態でリリースされます