• Stars
    star
    455
  • Rank 96,175 (Top 2 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Ruby static compiler.

RubyFlux: a Ruby to Java compiler

RubyFlux is a compiler that turns a Ruby codebase into a closed set of .java source files suitable for running on any JVM with no additional runtime requirement.

A .java file is produced for the toplevel of each file and for each Ruby class declaration encountered. Methods are emitted as normal Java methods, but with an abstract implementation on RObject so all dynamic calls can simply be Java virtual calls. The rest of Ruby syntax maps to mostly what you'd expect in Java code.

Note that this is a young project and it is not yet considered stable for general use.

On the Net

Github repository: https://github.com/headius/rubyflux

Mailing list: https://groups.google.com/forum/?fromgroups#!forum/ruby_flux

Getting Started

  1. Clone the repository
  2. From the repo dir, run "mvn package". You only need to do this once.
  3. Compile and/or run a target .rb file in one of several ways
    • Generate Java sources directly, compile, and run
      • jruby -I target:src/main/ruby src/main/ruby/ruby\_flux.rb target.rb
      • javac target.java
      • java target
    • Generate Java sources via the Rakefile
      • `rake compile[target.rb]
      • Sources are output to build/ in the same dir as target.rb
    • Generate, compile, and run via the Rakefile
      • `rake run[target.rb]

Usage

Here's an example session for using RubyFlux today:

# The file we want to compile

$ cat fib.rb
def fib(a)
  if a < 2
    a
  else
    fib(a - 1) + fib(a - 2)
  end
end

puts fib(40)

# First need to build the compiler's jar

$ mvn package
<maven noise>

# Provide the target file to 'rake run'.
#
# The Ruby sources are translated to .java and all support code is copied out
# of RubyFlux for the compilation step. That source is then compiled and run.
# to compile

$ rake run[fib.rb]
jruby -I target:src/main/ruby src/main/ruby/ruby_flux.rb fib.rb
javac fib.java
java fib
102334155

More Repositories

1

thread_safe

This project has been absorbed by ruby-concurrency/concurrent-ruby
Java
282
star
2

ruby-atomic

Atomic reference implementation for Ruby
Ruby
198
star
3

bitescript

The BiteScript API and language
Ruby
152
star
4

mirah

Mirah has moved to http://github.com/mirah/mirah
Ruby
114
star
5

invokebinder

A Java DSL for binding method handles forward, rather than backward
Java
102
star
6

duby

The Duby Programming Language
Ruby
100
star
7

jruby-pg

A JRuby version of the "pg" gem.
Java
69
star
8

jo

Implementation of key Go (lang) features for (J)Ruby
Java
65
star
9

indy_deep_dive

Examples from my invokedynamic "deep dive" talk
Java
51
star
10

spoon

A fork/exec replacement for FFI-capable implementations
Ruby
47
star
11

surinx

A simple dynamic language for the JVM
Java
43
star
12

cloby

A Clojure Ref/STM plugin for JRuby
Java
35
star
13

osx-on-linux

Configurations and guides to making Linux feel like OS X
CSS
34
star
14

luaj

Java
33
star
15

boing

Preloader-aware command runner for JRuby, a la Spring.
Ruby
30
star
16

dexclient

A wrapper around the "dex" tool from Android to use it as a library
Java
25
star
17

clojr

A JRuby ext wrapping Clojure's data structs as efficiently as possible
Java
21
star
18

forkjoin.rb

A JRuby extension/wrapper around the Java 7 Fork/Join framework
Java
19
star
19

LogCompilation

The LogCompilation tool from OpenJDK, as-is.
Java
18
star
20

redblack

A red/black tree impl and bench
Python
17
star
21

weakling

A modified WeakRef impl for JRuby plus some weakref-related tools
Java
15
star
22

lazy_enumerator

A pure-Ruby implementation of Ruby 2.0's Enumerator::Lazy
Ruby
14
star
23

options

A small library for managing sets of JVM properties to configure an app or library.
Java
14
star
24

hprof2

A fork of the "hprof" JVMTI demo from OpenJDK, which instruments JVM bytecode via the JVMTI APIs.
C
13
star
25

jruby-cdc

JRuby stripped down to run on the Java ME CDC profile
Ruby
12
star
26

jcd

JRuby version of MacRuby's Grand Central Dispatch wrapper
Java
11
star
27

mediakiller

A converter for MediaWiki markup to other formats
Ruby
10
star
28

jibernate

A JRuby/Hibernate integration example, maybe eventually a full API
Ruby
8
star
29

jruby-spymemcached

It's what you think it is.
Java
8
star
30

netty-examples

Ports of the examples from Netty
Ruby
8
star
31

backport9

Backports and utilities to support Java 9 and higher on Java 8
Java
8
star
32

hackit

A small utility to take advantage of various Windows desktop/window manager hacks.
C++
8
star
33

rx

Tim Bray's pure-Ruby XML parser
Ruby
8
star
34

to_source

JRuby to_source (and to_ast) using jrubyparser
Ruby
7
star
35

xni

A possible new C API for extending Ruby impls
Java
7
star
36

refractor

Utilities to generate direct-invoking stubs, avoiding reflective calls.
Java
6
star
37

protoj

Experiment in generating prototype classes on JVM similar to V8
Java
5
star
38

unsafe-fences

A wrapper around the Java 8 fences API for you to compile against.
Java
4
star
39

railsunder

My Rails Underground demos
Ruby
4
star
40

joniguruma

A pure-Ruby stub to emulate the Oniguruma gem on JRuby
Ruby
4
star
41

jruby-handle-compiler

An experiment in compiling JRuby AST nodes to method handles
Java
4
star
42

quercus

Quercus: Caucho's PHP on the JVM
Java
4
star
43

markdown_meta

markdown_meta is a meta-gem for markdown parsing and content generation.
3
star
44

jruby-demos

Demos for JRuby presentations at conferences
Ruby
3
star
45

jmx_jruby

A JMX wrapper library for JRuby
Ruby
3
star
46

rubytidy

A tool like perl's "perltidy" for reformatting Ruby source.
Ruby
3
star
47

sioc

Scheme InOneClass
Java
3
star
48

indy-examples

Examples and toys relating to invokedynamic
Java
3
star
49

jruby-stm

A thin wrapper around Clojure's STM for JRuby
Java
3
star
50

gc_tests

Ruby scripts designed to test, stress, monitor, or demonstrate GC in Ruby
Ruby
3
star
51

unsafe-mock

A mock of sun.misc.Unsafe for building against.
Java
3
star
52

jruby_gc_stats

GC stat-monitoring methods similar to Ruby Enterprise Edition
Ruby
3
star
53

modulator

Java
2
star
54

butthurt

2
star
55

rackup_thing

Ruby
2
star
56

ChaosBazaar

A port of ControlTower to work atop JCD
C
2
star
57

ruby-concurrency

The online book on concurrency in Ruby
2
star
58

coro-mock

A small mock library for compiling JVM coroutine-utilizing code on JVMs without coroutines
Java
2
star
59

sequence_counter

Examples of single and multi-threaded algorithms with incremental optimizations
Ruby
2
star
60

bone_utils

Utilities and scripts for the BeagleBone
Ruby
2
star
61

rubyvm_mvm

Implementation of MRI's MVM API for JRuby
Ruby
2
star
62

indifier

A tool for converting various Java calls into invokedynamic calls, for fun and profit.
Java
2
star
63

jpager

Example of using Java 7 ProcessBuilder to launch an interactive pager
Ruby
1
star
64

jruby-autolink

A JRuby wrapper around the autolink-java library to provide autolinking like rinku
Ruby
1
star
65

core-benchmarks

Ruby
1
star
66

jruby-extras-demo

Demonstration of some "extra" libraries that come with JRuby.
Java
1
star
67

debugr

A JVM/JDI-based debugger written in Ruby
Ruby
1
star
68

indy-crasher

Ruby
1
star
69

byte-string-examples

Java
1
star
70

rubyconf2011

Ruby
1
star
71

jsr166y-gem

A gem containing the jsr166y jar file
Ruby
1
star
72

jdi_objectspace

A primitive implementation of Ruby's ObjectSpace using the Java Debug Interface
Ruby
1
star
73

pgrailsbench

Ruby
1
star
74

jsr292-mock

Mock versions of java.lang.invoke from Java 7-8 for compilation
Java
1
star
75

singletonizer

A way to add singleton methods to objects without creating singleton objects
Ruby
1
star
76

dcpu-16-j

Java implementation of notch's DCPU-16
Java
1
star
77

graal

Java
1
star