2021å¹´3æ5æ¥ã«ãmruby 3.0.0 ã®ãªãªã¼ã¹ãããã¾ãããããã§ã¨ããããã¾ãï¼
ããã«é¢é£ãã¦ãªã®ããmrubyãããããå§ãããã¨ããããã®ã¨ããã©ããªã£ã¦ãã¾ããã¨ãã質åãã¡ããã¡ããåãããããã¤ã¼ããæè¦ãããããããã«ãªãã¾ããã
ä¸æ¹ã§ãã©ããã¦ãæ å ±ãå¤ãããããã¯å¤ãã®mgemã®ã¡ã³ããã³ã¹ç¶æ³ãæªãããã«è¦ããããªã©ã®åå¦è ã«ã¨ã£ã¦ã¯é£ããç¶æ³ãåºãã£ã¦ãããå³ããæ°æã¡ã«ãªã£ãããå³ããææ³ãè¿°ã¹ããããã¦ããæ¹ãããããã«æãã¾ããããã¦ããã®ææ³ä¸ã«ã¯èª¤è§£ãå«ã¾ãã¦ããããã§ãã
ããã§ãã£ãããå°ãã§ããå¿æ§ãããã§ããããã«ããããã触ã£ã¦ã¿ãæ¹ã ã«å¯¾ãã¦ã®èªåã®èããã¾ã¨ãã¦ãããã¨æãã¾ããã
ï¼ããã«ããã¨ãåºæ¬çã«æ¬å稿ã¯ãã¡ã¦ã¼ã¶ããããWebã¤ã³ãã©ã«é¢ããã¦ã¼ã¶ã¨ãã¦ã®è§£éãªã®ã§ãMatzãã¯ããã¨ããä»ã®mrubyé¢ä¿è ã¨éãç®æãããã ããã¨æãã¾ãããã®è¾ºãã¯é©å®çªã£è¾¼ãã§ããã ããã°ã¨ããæ°æã¡ã§ãï¼
ãªããç§ã¯mrubyã«é¢ãã¦ã¯ããã¤ããããããã°å ±åãéã£ã¦ããçµç·¯ã¯ããã¾ãããåºæ¬çã«ã¡ã³ããã³ã¹ããªãªã¼ã¹ããã¸ã¡ã³ãã«ã¯é¢ãã£ã¦ããªãç«å ´ã§ãã
ãã ã3.0.0ã®ãªãªã¼ã¹åã«ã¯ãMatzå«ãã³ã¢éçºãã¼ã ã«ãå°ãã ãã話ãããã¦ããã ãæ©ä¼ã¯ããã ãã¦ãã¾ãã
ãããããCRubyã¨ã©ãéãã®ã
ã¾ããmrubyã触ããæ¹ã®å¿µé ã«ããã¦ã»ãããã¨ã¨ãã¦ãmrubyã¯CRuby(MRI)ã§ã¯ããã¾ãããéãå®è£ ã§ããã¨ãããã¨ãã¾ãã¯è¦ãã¦ããã¦ã»ããã¨ããã¨ãããããã¾ãã
mrubyã¯CRubyã¨å ¨ãåããã¨ããããã¨ãç®çã¨ãã¦ãã¾ããï¼ã¨ç§ã¯æã£ã¦ããï¼ã
ä¾ãã°ãçµã¿è¾¼ã¿ã®ç°å¢ã«ããã¦ã¯ããããUNIXçãªãã¡ã¤ã«ã·ã¹ãã ãç¨æããã¦ããªãå ´åãããã¾ãããããã£ã¦mrubyã¯ãã¡ã¤ã«ãIOã«é¢ããã¯ã©ã¹ç¾¤ãå¤ããå½¢ã§ãã«ããã§ããããã¾ããCRubyã«ããã¦ããã¡ã¤ã«ãIOã®ãããªåºæ¬çãªã¯ã©ã¹ç¾¤ãç¡å¹åãããã¨ã¯å°é£ã ã¨æãã¾ãããã©ã®é¨åãæä½éã®ã³ã¢ã«ããããã®èããéããã ã¨ãããã¨ã¯ç解ããªãã¨ãä¸è¦ãªæ¸æããè¦ãããã¨ã«ãªãããããã¾ããã
ãã®ä¸ã§ãçµã¿è¾¼ã¿ã§ä½¿ããããããRubyãããçç£æ§ãä¸ããããã¨ããç¹ãèæ ®ãã¦ã
- mrubyã®ã³ã¢ã«æ®ããã®
- mrubyã®æ¨æºæ·»ä»mgemã«åãåºããã®
- mrubyã®ä¸å¤®ãªãã¸ããªã«å«ããããµã¼ããã¼ãã£ã«è²ããã®
ã決å®ãã¦ãã¾ããã¾ããä¸è¨ã®ä¸ãã2çªãã¾ã§ã®é¨åã¾ã§ã®ç·å¼ãã¯ãRubyã®ISOä¸ã§ã®ä»æ§ã§ãã ISO/IEC 30170:2012 ãèæ ®ãã¦ãã¾ããããããmrubyã¯Ruby 1.9äºæã ãã¨ããæ å ±ãããã¾ãããããã¯ãISO/IEC 30170:2012ã®ä½¿ç¨ãã»ã¼Ruby 1.9ç¸å½ãªã®ã§è¨ããã¦ããã¨ãããã¨ã§ãã Ruby 1.9ç¸å½ã®å¤ãä»æ§ã®ã¾ã¾éçºããã¦ããã¨ãã訳ã§ã¯ããã¾ãã ãCRubyã®ä¾¿å©æ©è½ã¯ãmrubyã®ç®çã«åããªãç¯å²ã§éæãã¼ãããã¾ãã
ãã¨ãã°ãã¼ã¯ã¼ãå¼æ°ããã¼ã£ã¡æ¼ç®åããFiberã®ãããªä¾¿å©ãªã¯ã©ã¹ã¯mruby 2.1ã®æ®µéã§å©ç¨ã§ãã¾ãããmruby 3ã§ã¯1è¡defãªã©ããµãã¼ããã¦ãã¾ã ãä¸æ¹ã§ãIntegerã®çµ±åãã®ãããªä»æ§ã¯ã2.1ã®æ®µéã§ã¯Fixnumãæ®åãã3.0ã§çµ±åãããããã«ãªã£ãããªã©ã¿ã¤ãã³ã°ã®éããããã¾ãã
ãã®è¾ºããã©ã®ä»æ§ãã©ã®tierã«å ¥ãããã¨ãããå¡©æ¢ ãã¯ãç§ã®èãã§ã¯æå¾ã®æå¾ã®è©°ãã®é¨åã§ã¯Matzã®ææ§ã«æ ã£ã¦ããã¨ãããããããã«æãã¾ãããã ããã®ç¹ã¯ããããCRubyã§ãã£ã¦ããããªã®ã§ããããããã®ã ã¨æãã¾ãããç§ã¯å¿ ãããå¦å®çã«ã¯èãã¦ãã¾ããã
CRubyã¨mrubyã®éãã«ã¤ãã¦ããWebã§ä½¿ãã mrubyã·ã¹ãã ããã°ã©ãã³ã°å ¥éãã®23ãã¼ã¸ã«ããå³ãå¼ç¨ãã¾ãã
å人çãªmrubyã®å¼·ã¿ã®ç解
mruby ã«é¢ããæ å ±ã¯åè¿°ããã¨ããã¾ã ã¾ã å°ãªããå¤ããã®ãæ··å¨ããã¨ããæãã§ãåºæ¬çã«åå¼·ã¯ã¿ãã ã¨æãã¾ããããã§å¤ã«ãã¾ããã¦åå¦è ããããï¼ã¨è¨ã£ã¦ãã¾ãã®ã¯ç§ã®æ§æ ¼ä¸ã§ããªã*1ã
ãã ãmrubyã¯ãã¼ãã¦ã§ã¢ç³»ã¯ãã¡ããã§ãããã½ããã¦ã§ã¢ã¸ã®çµã¿è¾¼ã¿ã«ããã¦ç¹ç°ãªä½ç½®ä»ããæã£ã¦ããããã®ç¹ãæ°ã«ãã£ãæ¹ã«ã¯é¢ç½ãæ¦å¨ã«ãªãã¨èãã¦ãã¾ãã
mrubyããã«ãããã¨ãä¸éææç©ã¨ãã¦ã¢ã¼ã«ã¤ããã¡ã¤ã« libmruby.a
ãçãã¦ãã¾ãã以ä¸ã¯Linuxã§ã®ä¾ã§ãã
$ find build/host -name 'lib*.a' build/host/lib/libmruby_core.a build/host/lib/libmruby.a build/host/mrbc/lib/libmruby_core.a
ãã® libmruby.a
ãä½è
ãã¨ãã話ããã¾ãã
mrubyã¯ããã«ãã®ããã»ã¹ã®éã«ãå½ç¶ãªããã³ã¢ã«å¿ è¦ãªCè¨èªã®ã½ã¼ã¹ãä¸éããªãã¸ã§ã¯ããã¡ã¤ã«ã«ã³ã³ãã¤ã«ãã¾ããå®ã¯ããã¨åæã«ãRubyã®ã¹ã¯ãªãããã¡ã¤ã«ï¼æ¡å¼µåã.rbã®ããããRubyã®ãã¡ã¤ã«ï¼ããmrubyã®ä¸é表ç¾ã«ã³ã³ãã¤ã«ãããããCè¨èªã®é åã«ãã¼ã¿ã¨ãã¦åãè¾¼ã¿ããããã³ã³ãã¤ã«ãããªãã¸ã§ã¯ããçæãã¦ãã¾ãã
ã©ãããCã®ãã¡ã¤ã«ãåããããã¯ãåããä¸ç·ã«çæããã mrbc
ã¨ããã³ãã³ããå©ç¨ããã°åããã¾ãã
$ cat hello.rb module Hello def hi "hi" end end puts Hello.hi $ ./bin/mrbc -B sample -S hello.rb $ cat hello.c #include <mruby.h> #include <mruby/proc.h> #include <mruby/presym.h> #define mrb_BRACED(...) {__VA_ARGS__} #define mrb_DEFINE_SYMS_VAR(name, len, syms, qualifier) \ static qualifier mrb_sym name[len] = mrb_BRACED syms static const mrb_pool_value sample_pool_2[1] = { {IREP_TT_STR|(2<<2), {"\x68\x69"}}, }; static const mrb_code sample_iseq_2[9] = { 0x35,0x00,0x00,0x00,0x51,0x02,0x00,0x39,0x02,}; mrb_DEFINE_SYMS_VAR(sample_lv_2, 1, (MRB_OPSYM(and), ), const); static const mrb_irep sample_irep_2 = { //... }; //... static const mrb_code sample_iseq_0[24] = { 0x13,0x01,0x61,0x01,0x00,0x62,0x01,0x00,0x14,0x01,0x1f,0x02,0x00,0x2f,0x02,0x01,0x00,0x2f,0x01,0x02, 0x01,0x39,0x01,0x6b,}; //...
ããã«ããã®ãCã¨Rubyããããã®ãã¡ã¤ã«ããªãã¸ã§ã¯ããã¡ã¤ã«ã«ã³ã³ãã¤ã«ãããã¤ãã©ã¤ã³ã¯ãå©ç¨ã®ããã«æå®ããmgemå ¨ã¦ã«å¯¾ãã¦ãè¡ããã¾ãã
ããã¦æçµçã«ããããã®ãªãã¸ã§ã¯ããã¡ã¤ã«ãã¾ã¨ãã¦ãªã³ã¯ãã libmruby.a
ã¢ã¼ã«ã¤ãã«åºãã¾ãã
ããã¾ã§ã®è©±ãã¾ã¨ããã¨ãmrubyã¯ã以ä¸ã®3ã¤ã®å«ã¾ããã¢ã¼ã«ã¤ãä¸å¼ãåºãããã¨ãã§ãããã®ã¢ã¼ã«ã¤ãããªã³ã¯ããã°èªåã ãã®libmrubyãæ§ã ãªããã°ã©ã ã«çµã¿è¾¼ãããã¨ããç¹ãç¹å¾´çã ã¨èãã¦ãã¾ãã
- mrubyããã°ã©ã ã®å®è¡ã«å¿ è¦ãªç°å¢ä¸å¼ï¼ãã¼ãµãVMå®è¡æ©ãªã©ï¼
- mrubyã®åºæ¬çãªã©ã³ã¿ã¤ã ã©ã¤ãã©ãª
- 追å ã§ä¾åãã¦ããmgemã©ã¤ãã©ãª
ãããã mruby
ã³ãã³ããã libmruby.a
ãçµã¿è¾¼ãã ãã ã®ããã°ã©ã ã«éããªã ãã¨ããç解ãã§ããã¨ãmrubyã®æ§è³ªã®ç解ãé²ãã ã¨è¨ããããããã¾ããã
ããã¦ãã® libmruby.a
ãApacheã¢ã¸ã¥ã¼ã«ã«ãªã³ã¯ããã mod_mruby ã«ãªããã nginx ã«ãªã³ã¯ããã ngx_mruby ã«ãªããã¨ãããã¨ã«ãªãã¾ãã
ãããã£ããå®è¡ã«å¿ è¦ãªå ¨ã¦ãã¢ã¼ã«ã¤ãã«åºããæ©è½ã¯å®ã¯LuaãMicroPythonãåãã¦ããããã§ãããmrubyã¯Rubyãããæè»ãªææ³ãDSLã使ãããå ´åã§ãã£ããããããã¯æ´ç·´ãããmrubyã®C APIãç¨ãã¦å¹ççã«ãã¤ã³ãã£ã³ã°ãæ¸ãããå ´åã«é常ã«åãçºæ®ããã¨æãã¾ãã
ä¸æ¹ã§ãã¨ãã«Webéçºè
ã§CRubyãä¸å¿ã«æ¸ãã¦ãã人ã®å ´åããã® libmruby.a
ã®ç¨éããã³ã¨ããªããã¨ãããããããã¾ããï¼ç§ã¯ããã§ããï¼ãããããæ¹ã¯ç°¡åã«ã§ãCè¨èªãç¹ã«Linuxãªã©ã®ã·ã¹ãã ããã°ã©ãã³ã°ç¨éã®Cè¨èªãåå¼·ããã¨ç解ãé²ãã ããä½ãã¢ã¤ãã¢ãæµ®ãã¶ã®ã§ã¯ãªããã¨æã£ã¦ãã¾ãã
ããããå¦ã¶çæ§ã¸
é·ã ã¨æ¸ãã¦ãã¾ããããå®ã¯Webãã¤ã³ãã©åéã§ã®mrubyã¯ç¨éããããã ã¨èãã¦ãã¦ããããæå¤ã¨ç«¶åãå¤ãã£ããï¼LuaãMicroPythonãã·ã¹ãã ããã°ã©ãã³ã°åéã§ã¯ããããGoã¨Rustã¨ããå¼·çãªç«¶åããã¾ãï¼ãã©ããã¦ãCè¨èªï¼ãããã¯C FFIï¼ã®ç¥èããªãã¨å¼·ã¿ãçãããããªãã£ãããã¦ãå¾®å¦ã«ã¦ã¼ã¶ã伸ã³ãªãã£ãããé¢ãã¦ãã¾ã£ãããã¦ããç¾ç¶ãããããã«æãã¾ã*2ã
ããã§ãããã·ã¹ãã ã®æ·±æ·µã«Rubyã決ãããã¨ãã極ãã¦ã¢ããããã°ã©ãã³ã°ä½é¨ãã§ããã®ã§ãç§ã®ãããªéçºè ã«ã¯ãã¾ããªãé åãæã£ãè¨èªã ã¨èãã¦ãã¾ãã
ã¾ããmgemã®ã¨ã³ã·ã¹ãã ã¯ä¸è¿°ã®ããã«ãªããªãå³ããç¶æ³ãããã¾ãããããã§ãææãæã£ã¦ä¿å®ãããã¨èãã¦ããéçºè ã¯ãããããã¾ãããP/Rãæ¥ãã対å¿ãã¦ãããæ¹ã¯ãã£ã¨å¤ãã§ãã
ããã¦ãªã«ãããmruby 3ãåºãã¨ããMatzå§ãã³ã¢éçºè ã®æ ç±ã¯ã¾ã ã¾ã è¡°ãã¦ããã¾ããããã®äºå®ã¯å¤§ããã¨æãã¾ãã
ããããå§ããçæ§ã¸ã®æ å ±ã¨ãã¦ã¯ãã³ãã¥ããã£ããããã®ã¨ãã¦ãruby-jp Slackã® #mruby ãã£ã³ãã«ãããã¾ããï¼æ¥æ¬èªã§ï¼ã¢ã¯ãã£ããªéçºè ã¨äº¤æµããããå ´æã¯ä»ã¯ããã§ã¯ãªããã¨æãã¾ããã¾ãã¯ãTwitterãªã©ã«æç´ãåãæµãããã¯ããã«åå ãã¦ãç¸è«ãè°è«ãã¢ã¤ã¢ã¤ã®è¡¨åºããã¦ãã£ãæ¹ãçç£çããªï¼ããªã©ã¨æã£ã¦ãã¾ãã
ruby-jp Slackã¸ã®ãªã³ã¯ãç½®ãã¦ããã¾ãã
ã¾ã¨ã¾ããªãã¾ã¨ã
mrubyããããã¨ã³ã·ã¹ãã ã¯è¥å¹²ç¸®å°ãã¦ãã¾ãã¾ããããmruby ã³ã¢ã¯ã¾ã ã¾ã ããæ°ãããã¾ãããããããã¢ã¯ãã£ããªäººãã¡ã§æ°ããã¨ã³ã·ã¹ãã ãä½ã£ã¦ããã¿ã¤ãã³ã°ãªã®ããããã¾ããã
ãã¡ãããªã¼ãã³ã½ã¼ã¹ãã³ãã¥ããã£ããªãã³ãªã®ã§ãããããããã«ãããããªãã®ã§ããã
ããã¦æè¿åºãmruby 3ã¯ã¡ã¢ãªãããããªã³ãã®å¤§å¹ æ¹åãªã©ãéæãã極ãã¦è¯ããªãªã¼ã¹ã§ãããã®è¨äºãæ©ä¼ã«ãmrubyã®é¢ç½ãç¨éãæ¢ãã¦ãããæ¹ãå¢ããã¨å¬ããã§ãã
[PR]
å®ã¯è²ã ãã®è¨äºã«æ¸ããå 容ãããã¡ãã£ã¨ä¸å¯§ã«æ¸ããã®ããmrubyã·ã¹ãã ããã°ã©ãã³ã°ãã ã£ãããã¾ãã®ã§ãæã«ã¨ã£ã¦ã¿ã¦ãã ã...ã...
Webã§ä½¿ããmrubyã·ã¹ãã ããã°ã©ãã³ã°å ¥é
- ä½è :è¿è¤å®æºæ
- çºå£²æ¥: 2020/11/25
- ã¡ãã£ã¢: Kindleç
é»åã®å ´åãKindleãããã§ããæ¬ã®æ£®ã§PDF/EPUBãè²·ãã¾ãï¼ããã¨ãå®ã¯é»åã¯äºè²å·ãã§ãï¼
https://book.mynavi.jp/manatee/c-r/books/detail/id=119864
ã¨ããããPRç®çã§ã¯ãªããã§ãããããããç§ã®mrubyä½é¨ã«ã¤ãã¦ã¯ããã®æ¬ã«å¤§ä½æ¸ãããã¨ããé¢ããããèªå°ããããå¾ãªããèªç±ã«æ¸ããã¦ãããç·¨éããã®ããã«ãå®ããããªã£ãããã