The Ruby VM: Episode I ã¸ãã訳
Matz にっき(2007-02-17) ãã The Ruby VM: Episode I ã¸ã
Google 翻訳 ã®å©ããåãã¦ãã¸ãããªè¨³ãã¤ãã¦ã¿ã¾ããã誤訳æºè¼ã ã¨æãã¾ãã®ã§ãçªã£è¾¼ã¿å¤§æè¿ã§ãã
ããã«ã¡ã¯ããäºäººãç§ã®è³ªåã«åçãããã¨ãåæãã¦ããããã¨ã«æè¬ãã¾ããå§ãã«èªå·±ç´¹ä»ã¨ Ruby ã®éçºã«ãããããªãã®å½¹å²ãæãã¦ãã ããã
æ¾æ¬ããï¼ä»¥ä¸ Matzï¼:
ç§ã¯ããã°ã©ãã³ã°è¨èª Ruby ã®è¨è¨è ã§ãããæåã®å®è£ è ã§ããæ¬å㯠ããã²ã ã¾ã¤ãã¨ãè±èªã 㨠You-Key-Hero Matz-Motor ã¿ããã«èãããã§ãããããã§ãè¦ããã«ãçºé³ããã«ãé·ãããã®ã§ãç§ã®ãã¨ã¯åã« Matz ã¨å¼ãã§ä¸ããã
Ruby ã®éçºã¯ 1993 å¹´ããè¡ã£ã¦ãã¾ããç¾å¨ãRuby ã¯é常ã«è¤éã«ãªããæ§è½é¢ã§åé¡ãæ±ãã¦ãã¾ããã¤ã³ã¿ããªã¿ãæ¸ãç´ããã¨ããææ§ãªè¨ç»ã¯é·å¹´æã£ã¦ãã¾ããããç¾å¨ã®ã¤ã³ã¿ããªã¿ãæ¾ãåºãã¦ã¾ã§ãæ°ããã¤ã³ã¿ããªã¿ãéçºãå§ããã¢ããã¼ã·ã§ã³ãå¾ããã¨ã¯ããã¾ããã§ããã
ãããªæãããã ãããç§ã®ベーパーウェアãããé¥ãã«æããæªæ¥ãããããã¨æããã YARV ãæã£ã¦æ¥ã¾ããããããããã¯åãã¾ã â ããã§ç§ã¯å½¼ã«ã³ã¢ã®å ¬å¼ãªéçºè ã®å½¹å²ãä¾é ¼ãã¾ãããç§ã¯è¨èªè¨è¨ã¨å®è£ ã®ä¸¡æ¹ã楽ãã¿ã¾ãããè¨èªå®è£ ã®å¤©æã§ã¯ãªãã¨æã£ã¦ãã¾ããYARV ãè¦ãã¨ãã«ãè¨è¨ã«ãã©ã¼ã«ã¹ããã¨ããæ¥ãã®ãããããªããã¨æã£ãã®ã§ãã
ããã ããï¼ä»¥ä¸ ko1ï¼:
YARV ã¨ç§ã«é¢å¿ãå¯ãã¦ããã ãããã¨ã«æè¬ãã¾ããã¨ããã§ç§ã¯ "YARV" ãä½ã表ãã¦ããã®ããèãã¦ãã¾ããYet Anotherï¼å¥ã®ãã®ï¼ ã§ã¯ãªãããã§ãããã人ã¯ãYARV 㯠RubyVM ã§ã¯ãªããã¨æ示ãã¾ããããã YARV ã "YARV ain't RubyRM" ã®æå³ãªããYARV ã¨ã¯ä½ã§ããããï¼
ç§ã¯ ãããã¡ ããã ã§ãããããã¡ã¯ååã§ã"ãã¡" ã¯æ¥æ¬èªã§ "1" ã®æå³ãªã®ã§ãç§ã¯ "ko1" ãããã¯ãã¼ã ã«ãã¦ãã¾ããç§ã¯æ±äº¬...å¦é¨ã®å©æã§ããç§ã®ç 究対象ã¯ã·ã¹ãã ã½ããã¦ã§ã¢ãç¹ã«ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ãããã°ã©ãã³ã°è¨èªã並åã·ã¹ãã ãªã©ã§ãã日本 Ruby の会 ã®ã¡ã³ãã¼ã§ã日本 Ruby 会議 ã®ãã㪠Ruby ã®ã¤ãã³ããè¨ç»ãã¦ãã¾ãããRubyist Magazine ã®ç·¨éè ã®ä¸äººã§ãããã¾ããã¾ããNadokaãRavaãRucheme ã®éçºãè¡ã£ã¦ãã¾ãããããYARV - ã¾ãå¥ã®RubyVM ã®éçºè ã§ããã
Ruby éçºè ã¨ãã¦ã®å½¹å²ã§ããï¼ æ¾æ¬ããã® VM ãããã³ã°ã®æ¥½ãã¿ã奪ããã¨ã§ããããï¼
ãã®ã¤ã³ã¿ãã¥ã¼ã®ãã¤ã³ãã¯ãRuby ã¤ã³ã¿ããªã¿ã®æªæ¥ã«ã¤ãã¦èªã£ã¦ããã ããã¨ã§ãããã®ã¹ã¿ã¼ãã¨ãã¦ãYARV/Rite ãä½ãã説æãã¦ããã ãã¾ããï¼ å¾æ¥ã® Ruby ã¤ã³ã¿ããªã¿ã¨è¨è¨ä¸ãã©ã®ããã«ç°ãªã£ã¦ããã®ã§ããããï¼
Matz:
ç§ã¯è¨èªã®å®è£ ãããè¨è¨ã®æ¹ã«å¸¸ã«é¢å¿ãããã¾ãããã®ãã Ruby ã¤ã³ã¿ããªã¿ã¯å¸¸ã«ããããã¹ãç¶æ ãããé ãã¦ãã¾ããç§ã¯ä½æ¨ã«ãªã£ã¦ããå ¨ã¦ã®æå®ãåãåã£ãããã«æãã®ã§ãããããããã«æ§è½åä¸ãæãéããã«ã¯ã³ã¢å ¨ä½ãåå®è£ ããå¿ è¦ãããããã§ãããç§ã¯ 'Rite' ã¨ããéçºã³ã¼ãã®æ°ããã¤ã³ã¿ããªã¿ã 2001å¹´ã«è¨ç»ãã¾ãããããã®ããã¸ã§ã¯ããéå§ããã«è¶³ãååãªã¢ããã¼ã·ã§ã³ãå ¨ãããã¾ãããå¤åç§ã¯ä½ãã«å¿ãããã¾ããã¾ãã«æ æ°ãªã®ã§ãã
ãããªæã« ããã ããããã£ã¦ãã¦ã彼㮠YARV ãæã ã«è¦ãã¦ããã¾ãããããã¾ã§ã«ãä½äººã Ruby ã¤ã³ã¿ããªã¿ã®å®è£ ã試ã¿ã¦ãã¾ããããããã ããã ããæ©è½ã»ããã®å®è£ ã¬ãã«ã«éãã¦ãã¾ããï¼ãã®æç¹ã§ã¯ãã§ããç¾å¨ã¯ Ruby 1.8 äºæã® JRuby 㨠RubyCLR ãããã¾ãï¼ãããã§å½¼ã«æ°ããã³ã¢ã®éçºã«å ããããã«èªã£ãã¨ãããå½¼ãåæãã¦ãããã®ã§ãã
2007å¹´ 1æ 1æ¥ã彼㯠YARV ãæã ã®ãªãã¸ããªã® trunk ã«ãã§ãã¯ã¤ã³ãã¾ããã®ã§ãç¾å¨ã® Ruby 1.9 ã®å ¬å¼ã³ã¢ã§ããç§ã¯æªã matzruby ãã©ã³ãã§å¾æ¥ã®å®è£ ã®ä½æ¥ãè¡ã£ã¦ãã¾ããå¾æ¥ã®ã¤ã³ã¿ããªã¿ä¸ã§æ°ããè¨èªæ©è½ã試ãæ¹ãç§ã¨ã£ã¦ã¯æ¥½ã ããã§ãããæçµçã«ã¯æ°ããã¨ã³ã¸ã³ã«åãæ¿ããã¤ããã§ãã
YARV å®è£ ã®è©³ç´°ã¯ãããã ããã説æãã¦ãããã§ãããã
ã¤ã¾ã Rite ã¨ããå称ã¯ç½®ãå»ãã«ãã¦ãYARV ã使ãç¶ããã¨ãããã¨ã§ããããï¼ ããã¨ãããæç¹ã§ YARV ã¯å称ãå¤æ´ãããã®ã§ããããï¼
Matz:
ããã ãããç§ã«é ¼ã¿ã§ãããªãéããRite ã¨ããå称ããã®è¨èªã®ç¾è¡ä¸ä»£ã§ä½¿ç¨ããããã¨ã¯ãªãã§ããããæ¢ã« Ruby ã®ããã® 'VM' ã«ãªã£ã¦ããã®ã§ãããã ããã YARV ã®ã¾ã¾è¡ããã©ãããç§ã«ã¯åããã¾ããã
ko1:
YARV ã¯æ¶æ» ãã¾ãã :)
å®éããã¼ã¯ã¼ã "yarv" ãæ§é ä½åãé¢æ°åããã¡ã¤ã«åããåé¤ãã¦ãã¾ããYARV ã¯åã«ã³ã¼ãåã§ãããã¾ã¤ã㨠ããã«ãã£ã¦ã¤ãããããã®ã§ã¯ããã¾ãããç¾å¨ãYARV 㯠"Yet Another(å¥ã®ãã®)" ã§ã¯ããã¾ããããã®è¨äºã§ã¯ãå ¬å¼ãªãã¸ããªã® Ruby ãã©ã³ã¯ã®ææ°çã« "YARV" ã¨ãããã¼ã¯ã¼ãã使ãã¾ãã
第ä¸ã«ãYARV ã¯ä»®æ³ã·ã¼ã±ã³ã·ã£ã«å½ä»¤ãå®è¡ããã·ã³ãã«ã¹ã¿ãã¯ãã·ã³ã§ããå¾æ¥ã®ã¤ã³ã¿ããªã¿ï¼matzrubyï¼ã¯æ½è±¡æ§æããªã¼ï¼ASTï¼ãåç´ã«æ¨ªæãã¾ããããã¯æããã«é ãã®ã§ããYARV 㯠AST ã YARV ãã¤ãã³ã¼ãã«ã³ã³ãã¤ã«ãããããå®è¡ãã¾ãã
第äºã«ãRuby ã¹ã¬ãããå®è£ ããããã« YARV ã¯ï¼OS ãªã©ã§ãµãã¼ãããã¦ããï¼ãã¤ãã£ãã¹ã¬ããã使ç¨ãã¾ããããã¯æ¡å¼µã©ã¤ãã©ãªã§ããããã³ã°ã¿ã¹ã¯ãå®è¡ã§ãããã¨ãæå³ãã¾ããRuby ã®ä»æ§ã§ã¯ãããããã³ã°ã¿ã¹ã¯ã¯ Thread#raise ã«ãã£ã¦ä¸æãããã¹ãã§ãã詳細㯠[ruby-core:10252] ãã覧ãã ãããã¹ã¬ããçæã¯ï¼ã°ãªã¼ã³ã¹ã¬ããã®ï¼ matzruby ãããé ãã®ã§ãåæã«å¤æ°ã®ã¹ã¬ãããä½æããã¹ãã§ã¯ããã¾ããããã¤ãã£ãã¹ã¬ããã®ãµãã¼ãã¯ãï¼è¤æ°ã®ï¼ãã«ãã³ã¢ CPU ã®ãããªä¸¦åãã·ã³ä¸ã§è¤æ°ã® Ruby ã¹ã¯ãªããã並åã«å®è¡ã§ãããã¨ãããã¨ã§ã¯ããã¾ãããç¾å¨ã®å®è£ ã¯åæåé¡(å¤ãã®æ¡å¼µã©ã¤ãã©ãªã¯ã¹ã¬ããã»ã¼ããèæ ®ãã¦ãã¾ãããarray.cãstring.c ãªã©ãåç §ãã¦ãã ããã)ãé¿ããããã« Giant VM ããã¯ã使ç¨ãã¦ãã¾ãã
第ä¸ã«ãç§ã¯ç¹åå½ä»¤ãªã©ã®æ°å¤ãã®æé©åãè¡ãã¾ããããããã®æ©è½ã¯ç§ã YARV ãéçºãã¦ããç®çã§ãããããã®æé©åãã¯ããã¯ã«ãããToy ãã³ããã¼ã¯ã®å®è¡ãæ©ããªãã¾ããã
YARV ã¯ãã¼ãµã¼/æ§æ/ã¹ããã¯ï¼ã¾ã¤ã㨠ããã®æ¥½ãã¿ï¼ãGCï¼ã¡ã¢ãª/ãªãã¸ã§ã¯ã 管çï¼ãString/Array/Hash/Regexp ãªã©ã®æ¡å¼µã©ã¤ãã©ãªã¯å¤æ´ãã¾ããããã®ãããæååå¦çãªã©ã«ããã«ããã¯ãããå ´åãã¹ã¯ãªããã®å®è¡é度ã¯ä¸ããã¾ããã
ãäºæ¹ãRuby/YARV ã®ãã¼ã¸å®äºãããã§ã¨ããããã¾ããæ°å¤ãã®ä½æ¥ããã£ãã«éãããã¾ããããRuby çå ¨ä½ãé常ã«è奮ãã¦ãã¾ããããã¦ãã¼ã¸ãå®è¡ããããã¨ã§ãRuby ã®éçºæ¹æ³ã«ã©ã®ãããªå¤åãã¿ããã¾ããï¼
Matz:
è³è¾ã¯å¤ãã®ä½æ¥ãè¡ã£ã ããã ããã«ãªãããã¹ãã§ããç§ã¯éçºã®å ´ã matzrubyï¼å¾æ¥ã®ã¤ã³ã¿ããªã¿ç¨ãã©ã³ãï¼ãã trunkï¼the yarvï¼ã«ç§»è¡ãã¤ã¤ããã¾ããæè¿ãç§ã¯ trunk ã«å¹¾ã¤ãã®æ°æ©è½ãä¾ãã°ã¯ã©ã¹ãã¼ã«ã«ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨æ°ããªãã¼ã«ã«å¤æ°ã¹ã³ã¼ããå®è£ ãã¾ããã移è¡ã¯å²ã¨ããã«å®äºãããã¨ã§ãããã
å ã trunk 㯠ããã ããã®ææã§ããããçããã®ãç¹ã« ããã ããããã®å¤ãã®æå©ãã以åã«ãå¢ãã¦å¿ è¦ã§ããå¾æ¥ã®ã¤ã³ã¿ããªã¿ã«é¢ãã¦ã¯å ¨ã¦ï¼ãããå¤åã»ã¨ãã©ï¼ç¥ã£ã¦ãã¾ãããæ°ãããã®ã¯æªã ãã¹ããªã¢ã¹ã§ããç§ã¯æ°ãããã®ã«ååæºè¶³ãã¦ãã¾ããããæ確ã§ãè¯ãç·´ããã¦ãã¦ããããããæ©ãã®ã§ãã
ko1:
ãããã¨ããããã¾ããï¼å®éãruby ã³ã¼ããã³ãããããããã® CVS ã¢ã«ã¦ã³ããæã£ã¦ãã¾ãããï¼ç§ã¯ Ruby éçºè ã¨ãã¦ã¯åå¿è ã§ããããruby ã®éçºã«ãããå¤åãã©ããªããã¯åããã¾ãã:)
å ¨ã¦ã® Rubyist ãã¡ãå©ç¨å¯è½ãªãYARV ä¸ã§åä½ãã Ruby ã®æåã®è£½åãªãªã¼ã¹ã¯ãã¤ã§ããããï¼
Matz:
çãçãï¼ "ä»"ã
é·ãå¿ãï¼YARV ã¯æã ã® Subversion ãªãã¸ããªçµç±ã§æ¢ã«èª°ã§ãå©ç¨å¯è½ã§ããä»ãå ¥æãã¦ããã§éã¶ãã¨ãã§ãã¾ããããããæã ããããã¹ããããããå¤åã§ããã°ãæã ããã®æåã®å ¬å¼ "ãªãªã¼ã¹" 㯠2007å¹´ã®ã¯ãªã¹ãã¹ã§ããããç§ã¯ã©ããããèªåãæ æ°ã§ããããç¥ã£ã¦ããã®ã§ããã®ãªãªã¼ã¹ãç§ãã¤ã¾ããããªãæ§ã«åªåãããã¨æãã¾ã ;-)
http://blog.grayproductions.net/articles/2007/02/16/the-ruby-vm-episode-i