{"id":13682634,"url":"https://github.com/sisshiki1969/ruruby","last_synced_at":"2025-04-30T09:33:28.456Z","repository":{"id":38324939,"uuid":"214989983","full_name":"sisshiki1969/ruruby","owner":"sisshiki1969","description":"An alternative Ruby implementation by Rust.","archived":false,"fork":false,"pushed_at":"2023-12-29T05:34:59.000Z","size":4431,"stargazers_count":348,"open_issues_count":1,"forks_count":11,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-02T13:34:22.507Z","etag":null,"topics":["ruby","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sisshiki1969.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-14T08:33:05.000Z","updated_at":"2024-05-05T13:29:51.000Z","dependencies_parsed_at":"2024-08-02T13:22:31.908Z","dependency_job_id":"31840c6b-29a0-4c76-ba68-32c1754f1cd5","html_url":"https://github.com/sisshiki1969/ruruby","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisshiki1969%2Fruruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisshiki1969%2Fruruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisshiki1969%2Fruruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisshiki1969%2Fruruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sisshiki1969","download_url":"https://codeload.github.com/sisshiki1969/ruruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224206134,"owners_count":17273395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","rust"],"created_at":"2024-08-02T13:01:50.243Z","updated_at":"2024-11-12T02:31:16.598Z","avatar_url":"https://github.com/sisshiki1969.png","language":"Rust","funding_links":[],"categories":["Rust","Minor / Upcoming Rubies"],"sub_categories":[],"readme":"# ruruby ![ruruby](https://github.com/sisshiki1969/ruruby/workflows/Rust/badge.svg)![codecov](https://codecov.io/gh/sisshiki1969/ruruby/branch/master/graph/badge.svg)\n\nAn alternative Ruby implementation by Rust.\n\n## Features\n\n- Purely implemented with Rust.\n- No dependency on any other Ruby implementation such as CRuby(MRI), mruby, .. etc.\n- Hand-written original parser.\n- Virtual machine execution.\n- Simple mark \u0026 sweep garbage collector is implemented.\n- Supporting x86/posix, arm64/macos, x86/windows (thanks @jtran and @dmtaub!) . 64-bit arch only.\n\n## Related articles (sorry, currently only in Japanese)\n\n[Qiita: Rust でつくる（つくれるかもしれない）Ruby (You can (possibly) make Ruby.)](https://qiita.com/sisshiki1969/items/3d25aa81a376eee2e7c2)  \n[Qiita: ruruby: Rust でつくっている Ruby (Making Ruby with Rust)](https://qiita.com/sisshiki1969/items/4d76e69545ca1c26ed48)  \n[SpeakerDeck: Rust でつくるガーベジコレクタ (Garbage collector written in Rust)](https://speakerdeck.com/sisshiki1969/rustdetukurugabezikorekuta)\n\n## Implementation status\n\n[See Wiki.](https://github.com/sisshiki1969/ruruby/wiki/Implementation-status)\n\n## Optcarrot benchmark\n\n|    benchmark    |       CRuby       |      ruruby       |  rate  |\n| :-------------: | :---------------: | :---------------: | :----: |\n|    optcarrot    | 56.09 ± 0.13 fps  | 34.80 ± 0.08 fps  | x 1.61 |\n| optcarrot --opt | 130.53 ± 0.82 fps | 101.85 ± 1.08 fps | x 1.28 |\n\n\u003cbr/\u003e\n\nTo check other benchmark results, [see Wiki.](https://github.com/sisshiki1969/ruruby/wiki/Benchmarks)\n\nYou can see the results of optcarrot benchmark for ruruby and other Ruby implementations [here](https://github.com/mame/optcarrot/blob/master/doc/benchmark.md).\n\n## How to run ruruby\n\nTo build ruruby, You'll need installation of Rust.\nPlease be aware that **only nightly version of Rust works** for ruruby.\n\nTo run ruby program file on ruruby,\n\n```sh\n% cargo run tests/sample.rb\n```\n\nor\n\n```sh\n% cargo run --release -- tests/sample.rb\n```\n\nYou can launch irb-like interactive shell, omitting file name.\n\n```sh\n% cargo run\n```\n\nThere are some useful options for analysis and development. Use `features` flag of cargo.\n\n### `trace` option: bytecode trace execution\n\n```sh\n% cargo run --features trace -- tests/sample.rb\n    Finished dev [unoptimized + debuginfo] target(s) in 0.03s\n     Running `target/debug/ruruby tests/sample.rb`\n+++\u003e MethodId(552) Method[unnamed] \"/home/monochrome/ruruby/tests/sample.rb\"\n--------invoke new context------------------------------------------\nStack context:0x55be3bec7d00 outer:None prev_stack_len:0\n  iseq: Ref(0x55be3bedbc90)\n  self: #\u003cObject:0x00007f94e2b40140\u003e\n  lvar(0): w nil\n  delegate: None\n--------------------------------------------------------------------\n   0: CONST_VAL \"world\"                        tmp: 0    stack: 0   top:\n   5: SET_LOCAL 'w'                            tmp: 0    stack: 1   top: \"world\"\n   a: CONST_VAL \"Hello \"                       tmp: 0    stack: 0   top:\n   f: GET_LOCAL 'w'                            tmp: 0    stack: 1   top: \"Hello \"\n  14: TO_S                                     tmp: 0    stack: 2   top: \"world\"\n  15: CONST_VAL \"!\"                            tmp: 0    stack: 2   top: \"world\"\n  1a: CONCAT_STR 3 items                       tmp: 0    stack: 3   top: \"!\"\n  1f: O_SEND_SLF 'puts' args:1 block:None      tmp: 0    stack: 1   top: \"Hello world!\"\n+++\u003e BuiltinFunc puts\nHello world!\n\u003c+++ Ok(nil)\n  2e: RETURN                                   tmp: 0    stack: 1   top: nil\n\u003c+++ Ok(nil)\n```\n\n### `emit-iseq` option: dump bytecode\n\n```sh\n% cargo run --features emit-iseq -- tests/sample.rb\n   Compiling ruruby v0.3.1 (/home/monochrome/ruruby)\n    Finished dev [unoptimized + debuginfo] target(s) in 9.01s\n     Running `target/debug/ruruby tests/sample.rb`\n-----------------------------------------\n[MethodId(552)] Method: \u003cunnamed\u003e opt:true\nlocal var: 0:w\nblock: None\n  00000 CONST_VAL \"world\"\n  00005 SET_LOCAL 'w'\n  0000a CONST_VAL \"Hello \"\n  0000f GET_LOCAL 'w'\n  00014 TO_S\n  00015 CONST_VAL \"!\"\n  0001a CONCAT_STR 3 items\n  0001f O_SEND_SLF 'puts' args:1 block:None\n  0002e RETURN\nHello world!\n```\n\n### `perf` option: performance analysis per VM instruction\n\n```sh\n% cargo run --release --features perf -- tests/app_mandelbrot.rb \u003e /dev/null\n    Finished release [optimized] target(s) in 25.75s\n     Running `target/release/ruruby tests/app_mandelbrot.rb`\n+-------------------------------------------+\n| Performance stats for inst:               |\n| Inst name         count    %time  ns/inst |\n+-------------------------------------------+\n  PUSH_VAL          5385K     5.57       37\n  PUSH_NIL          3948K     3.97       36\n  CONST_VAL             2     0.00      100\n  SET_LOCAL          320K     0.39       43\n  GET_LOCAL          620K     0.66       38\n  SET_DYNLOCAL      4265K     4.69       39\n  GET_DYNLOCAL        16M    17.25       36\n  O_SEND            3925K     6.16       56\n  O_SEND_SLF         480K     0.93       69\n  O_SEND_N           160K     0.30       66\n  O_SEND_SLF_N        20K     0.04       67\n  DUP                 20K     0.03       51\n  CONCAT_STR            1     0.00      400\n  TO_S                  2     0.00      600\n  DEF_METHOD            1     0.00      300\n  RETURN            4032K     6.82       60\n  MRETURN             96K     0.20       74\n  ADD               3905K     6.26       57\n  SUB                320K     0.42       47\n  MUL               4225K     6.55       55\n  DIV                320K     0.41       45\n  SHL                160K     0.22       48\n  BIT_OR             160K     0.20       44\n  ADDI               160K     0.20       44\n  SUBI               140K     0.17       44\n  JMP_F_EQ           140K     0.19       49\n  JMP_F_GT          3905K     4.57       41\n  JMP_F_EQI          160K     0.22       49\n  GC                  697     0.75    38699\n  EXTERN              12M    32.82       96\n```\n\nInstruction name, total execution count, percentage in the total execution time, and\nexecution time per single instruction are shown.  \n\\* `GC` means garbage collection.  \n\\*\\* `EXTERN` means exectution of native methods.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsisshiki1969%2Fruruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsisshiki1969%2Fruruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsisshiki1969%2Fruruby/lists"}