Giter VIP home page Giter VIP logo

rubyflux's Introduction

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.

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

rubyflux's People

Contributors

headius avatar ianp avatar shawn42 avatar

Watchers

Glenn Nagel avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.