
Ahead-Of-time (AOT) Compiler Designed for Ruby - ksec
https://github.com/pmq20/ruby-compiler
======
bjpbakker
This is /not/ AOT compilation of ruby code.

It simply compiles a ruby interpreter and adds your code to the executable (as
memfs).

The output is an executable that /interprets/ ruby code.

~~~
pmq20
Currently it is just packaging, but when combined with work of @ko1 we could
achieve real compiling in order to boost start-up speed and also protect
intellectual properties.

I talked to @ko1 last year after his presentation about AOT compiling for Ruby
at RailsConf, and it seems like we were missing a piece of the puzzle at that
time, which is to preserve the file system structure after compiling, in order
to accommodate `__FILE__` and `require` calls. I achieved it now with the help
of
libsquash([https://github.com/pmq20/libsquash](https://github.com/pmq20/libsquash)).
So now in runtime every path that begins with `/__enclose_io_memfs__/` got
redirected to the memory, and so are your project files.

~~~
chrisseaton
Maybe you know something I don't, but I understand that Koichi's AOT is still
just translating the Ruby source code to bytecode which is then interpreted.
It isn't AOT to native code.

~~~
bjpbakker
You are correct. AOT compilation for ruby would translate the internal AST
into machine code.

While serializing Ruby files in byte code might be a good idea (I don't know
enought of the internals of MRI so I can't judge that), it's still not AOT
compilation

------
dankmemes420
[http://i.imgur.com/MVOSH81.png](http://i.imgur.com/MVOSH81.png)

I can't be the only one

~~~
hursortue
[https://duckduckgo.com/?q=%22that+just+works%22](https://duckduckgo.com/?q=%22that+just+works%22)

<Product name>. <What it does>, that just works. Made by <name> in <city> with
love.

------
ksec
A lot of people have complained about the lack / difficulties of Ruby Programs
distribution. I remember the Authors of Vagrant said one of the reason why he
switched to Go was that.

And this solves that problem.

------
funkaster
As suggested by other comments, this is not really AOT, more like a bundler
(not _that_ bundler) or packer. It prepacks a Ruby interpreter with your
files/libs/deps. Useful and interesting, but not an AOT.

------
kej
While still useful, this appears to be more of a bundler than a compiler, per
se.

------
mkarklins
How easy would it be to retrieve the ruby source code from the distributed
binary?

~~~
bjpbakker
Fairly easy. It's inside a memfs in data section in the binary.

