npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

v8ruby

v0.1.3

Published

A Ruby implementation that compiles Ruby to JavaScript and runs it on the V8 engine

Downloads

542

Readme

v8ruby

A Ruby implementation that compiles Ruby to JavaScript and runs it on the V8 engine (via Node.js). Your Ruby program becomes JavaScript and is JIT-compiled and executed by V8 — so V8 really is the engine running Ruby.

$ v8ruby -e 'puts "Hello from V8 Ruby!"'
Hello from V8 Ruby!

How it works

Ruby source
   │  src/lexer.js      tokenize (handles interpolation, heredocs, %w[], symbols…)
   ▼
 Tokens
   │  src/parser.js     recursive-descent + Pratt precedence → AST
   ▼
  AST
   │  src/compiler.js   two-pass: (1) scope analysis for Ruby local-variable
   │                    semantics, (2) emit JavaScript
   ▼
JavaScript ──► new Function('R', js)(R) ──► executed on V8
                         │
                   src/runtime.js   the Ruby object model + core classes
                                     (Integer, Float, String, Symbol, Array,
                                      Hash, Range, Proc, Struct, Enumerator,
                                      Comparable, Enumerable, exceptions, …)

Every method call and operator is compiled to a single dynamic-dispatch entry point, R.send(recv, name, args, block), so Ruby semantics are preserved:

  • Truthiness — only nil and false are falsy (0 and "" are truthy).
  • Integer vs Float1 / 2 == 0 but 1.0 / 2 == 0.5.
  • Everything is an object3.times, "x".upcase, nil.to_a.
  • Open classes, method_missing, respond_to?, operator overloading.
  • Blocks, procs, lambdas, yield, non-local return/break/next.
  • super, modules/mixins (include), Comparable, Enumerable.
  • Exceptionsbegin/rescue/ensure/retry, custom exception classes.

Usage

./v8ruby program.rb        # run a file
./v8ruby -e 'puts 1 + 1'   # run a one-liner
./v8ruby --dump program.rb # print the generated JavaScript
./v8ruby -v                # version (shows the underlying V8 version)

Installed from npm (npm install -g v8ruby), the same command is available as v8ruby.

(No build step and no dependencies — just Node.js.)

Supported language features

Literals (int, float, string with #{} interpolation, symbols, arrays, hashes, ranges, %w[]/%i[], heredocs <<~), all operators, multiple assignment and destructuring, splat/keyword/block/default parameters, if/unless/case/ while/until/for, ternary, &&/||/and/or/not, method calls with and without parentheses, safe navigation &., blocks ({} and do…end), procs and stabby lambdas (->(){}), endless methods (def f = …), classes with inheritance and super, singleton/class methods (def self.x), modules, attr_accessor, Struct, class_eval/define_method, and a large slice of the core library.

See examples/ for sample programs and test/cases/ for feature tests.

Tests

test/run.js is a differential test runner: it runs each test/cases/*.rb through both v8ruby and the real ruby interpreter (if installed) and diffs the output.

node test/run.js

Limitations

This is a from-scratch implementation of a large language; it targets the common core, not 100% of MRI. Notable gaps: no real threads/fibers, no full Regexp (simple String#match/gsub only), Rational/Complex are approximate, mutation of frozen objects isn't enforced, and only a subset of the enormous standard library is present.

License

MIT