[心得] JRuby - jrubyc

看板Ruby作者 (godfat 真常)時間17年前 (2007/10/29 15:50), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串1/1
斷線 >_< 我的 p 幣 >_< : → poga:不是說The compiler is complete嗎...? 不清楚 10/15 個人覺得,如果 JRuby 只是 interpreter, 實在意義不大 根本就只是慢上加慢,恐怕只能拿來做實驗而已? 但是如果有 compiler 那就完全不一樣了 :D 最直接的意義就是,不用灌 ruby, 只要有 jvm 就能跑 ruby program, 而現在真的很多地方都有 jvm, 這個平台大有利用價值... 於是去抓了 jruby, 想試試他的 compiler 用起來感覺如何。 設定設了半天,總算是可以用了....... 不是很難設定,只是手冊沒寫清楚,再加上 java 設定我不熟, 所以就試了半天才弄出來 = =b 大致上就是把 jruby 的 bin 設到 path 下, 然後 classpath 中除了 lib/jruby.jar 和 lib/asm-2.2.3.jar 要加入, 還要連 . 也加入 classpath.(我以為預設都會加,一直沒懷疑到這個問題) 這邊有個大致上的效能比較: http://www.headius.com/jrubywiki/index.php/JRuby_Compiler#Performance 老實講滿失望的,compile 過的 ruby 也只跟 ruby interpreter 差不多而已。 jruby 本身的 interpreter 更別說了,慢到不行了... 不過最大的問題是!! godfat benchmark 3.2$ jrubyc name.rb Error -- Not compilable: Can't compile node: RescueNode[] 居然不支援 rescue @@ 看來企圖用 bytecode 加速是完全失敗了...... 本來我是想試 yarv 的,不過弄半天老是有問題,所以轉戰 jruby 看來還是不太樂觀啊 或許還是得考慮 ruby-inline 或 swig 了... 至於其他小東西的話: godfat jruby 3.2$ ruby hello.rb hello jruby!! godfat jruby 3.2$ jruby hello.rb hello jruby!! godfat jruby 3.2$ jrubyc hello.rb godfat jruby 3.2$ java hello hello jruby!! 這倒是沒什麼問題 -_-b 再仔細看看上面那頁 wiki 上寫的: Notable things that do not compile in either safe or unsafe mode: * class and module definitions * singleton class and method definitions * blocks with arguments * method defs with optional, "rest", or block arguments * some method calls are unsafe, like "block_given?" and "local_variables" * splats and multiple assignment (a, b = b, a) 連 class 和 module 都不能 compile !? 看來我要等 jruby 2.0 甚至 3.0 才能正常使用我的 ruby code 了.... (不能用 class/module 跟不能用 ruby 搞不好差不了太多...) yarv 正式版快出吧!! -- 「行け!Loki!」(rocky ロッキー) -Gurumin ぐるみん 王子? XD -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.218.90.242

10/29 21:21, , 1F
不能用class跟module.. 那不是全部都不能用了嗎 -_-
10/29 21:21, 1F

10/29 21:30, , 2F
好個 JRuby compiler "finished", 是吧...
10/29 21:30, 2F

10/31 15:59, , 3F
有聽過了,看來只能期待XRuby
10/31 15:59, 3F

11/01 01:10, , 4F
試了一下 xruby, 看起來比 jruby 好用,但是缺 lib 缺很多
11/01 01:10, 4F

11/01 01:10, , 5F
gem 弄不起來就不繼續試了,因為我程式幾乎都要 gem
11/01 01:10, 5F
文章代碼(AID): #179P2sRd (Ruby)
文章代碼(AID): #179P2sRd (Ruby)