how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
-r
Short answer: You cant
Correct answer: The compiled code needs to incorporate an interpreter
or recompiler to answer the dynamic needs of Ruby. Study the
formidable techniques implemented in JRuby for that matter.
HTH
Robert
···
On Fri, Oct 1, 2010 at 6:40 AM, Robin <r@thevoid1.net> wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
-rr@thevoid1.net
--
The best way to predict the future is to invent it.
-- Alan Kay
It's possible in principle, but in practice you'd end up building a ruby interpreter as part of that and the performance speed up would be marginal without adopting a radically different design to that which is currently well understood.
And C++ might not be the most appropriate target language...
Ellie
Eleanor McHugh
Games With Brains
http://feyeleanor.tel
···
On 1 Oct 2010, at 05:40, Robin wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
----
raise ArgumentError unless @reality.responds_to? :reason
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
basically you'd need to "parse" the ruby, and then convert it into C++
(using correct types, et al). Unfortunately this wouldn't work for
ruby's more dynamic features, like eval, but would get you somewhere.
Mirah is an example of this, somewhat.
Cheers!
-r
···
--
Posted via http://www.ruby-forum.com/\.
* http://confreaks.net/system/assets/datas/234/original/20-nov-2009-09-30-towards-a-ruby-compiler-caleb-clausen-small.mp4?1284086243
* GitHub - coatl/ocelot: Caleb Clausen's type-inducting ruby-to-c converter
···
On Oct 1, 12:40 am, Robin <r...@thevoid1.net> wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
-r
If you really want to explore ruby compilation, you could look into
doing it via scheme. There are several scheme -> native compilers, and
scheme seems like the most rubyish target available. Be warned that it
will be a lot of work.
martin
···
On Fri, Oct 1, 2010 at 10:10 AM, Robin <r@thevoid1.net> wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
-rr@thevoid1.net
What's "awesome" is that not a soul on this thread has asked you a single clarifying question...
WHY do you want one and WHAT do you want to do with it?
···
On Sep 30, 2010, at 21:40 , Robin wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
my 3 cents:
1) static type-inferencing analyzers/compilers wouldn't help much in a
language where you can do something like monkey patching and modify
behaviour of classes at runtime: there's not many things remaining
static (for too long) in a ruby program
2) static type-inferencing analyzers/compilers could work if they were
whole-program compilers, but for a typical ruby program this could
mean a few hours or days of compilation time and memory swapping
3) static type-inferencing analyzers/compilers could work best for
ruby if they were JITs, but still wouldn't get you anywhere near the
performance of a static language by nature.
I second Robert.
Some of significant points to consider:
- Ruby is duck-typed and C++ is strictly typed. A Ruby variable can be
string at one point, a harsh at some instance, an array at some point, and
Fixnum at another point. This might be difficult to track when converted to
C++.
- Ruby and C++ are not closest syntactic relatives. Ruby has some
features (data structures, e.t.c) that make it incomparable to C++. With a
lot code spread over gems and with gems coming out almost daily), I do not
know how easy it can become to bring all that code to a C++ syntax.
- Coding styles among developers differ a lot in Ruby, because of its
flexibility
···
2010/10/1 Robert Dober <robert.dober@gmail.com>
On Fri, Oct 1, 2010 at 6:40 AM, Robin <r@thevoid1.net> wrote:
> how can we make a thing that compiles ruby into c++ source code?
> does anyone want to help me make one....
> -r
>
> r@thevoid1.net
>
>
Short answer: You cant
---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/\) |
Malawi
Cell: +265 999 465 137 | +265 881 234 717
*"Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good.." -- Kevin Scannell*
--
The best way to predict the future is to invent it.
-- Alan Kay
Hi all.
This might be slightly off-topic but something interesting would be to
look at a canonical Ruby interpreter written in Ruby, in the lisp /
scheme fashion.
I would be interested in knowing whether someone has done that
already.
Thanks.
It's possible, although many language features can't be supported, most
notably eval.
See Starkiller, a static type inferencing compiler for Python:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90.268&rep=rep1&type=pdf
···
On Thu, Sep 30, 2010 at 11:00 PM, Robert Dober <robert.dober@gmail.com>wrote:
Short answer: You cant
--
Tony Arcieri
Medioh! A Kudelski Brand
You just ruined the "awesome" by asking them. Didn't you? Just kidding.
Seriously, I believe these questions are not worth asking. It is 100%
possible in both principle and in practice to convert Ruby code into
another language where the output performs the same functions as the
original code. However, the output will have nothing to do with Ruby
in any way. It will just do the same things that the ruby code did. I
also believe that doing a "round trip", converting back to Ruby, is
also possible.
Before I would even consider asking the OP why and what for, I ask
myself if the benefits of such a tool would justify the immense effort
required to create it. I think the answer is no.
But, and just to get a feel for how much work will be involved, you
can try a few experiments. One interesting one would use Ruby itself
to accomplish part of this goal. Imagine overriding all the methods of
Array and Enumerable with methods that instead of executing generate
the language you are interested in. For example:
class Array
def initialize
$stdout.puts "vector<VALUE> a_#{some_id};"
end
def reverse
$stdout.puts "reverse(a_#{some_id}.begin(), a_#{some_id}.end());"
end
# etc...
end
Of course this is not meant to work, it is meant to illustrate what
might be involved. How would you handle generic values (like ruby's
VALUE struct)... these can hold anything from an int to a map of maps.
Duplicate ruby's? Probably. How would you handle identification (as in
generating identifiers) of the various objects? Do you need multiple
passes to in order to identify which headers you need add #includes
for? Probably.
It's not going to be easy, and I don't think the benefits, if there
are any, will be worth it.
Regards,
Ammar
···
On Sat, Oct 2, 2010 at 4:52 AM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
On Sep 30, 2010, at 21:40 , Robin wrote:
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....What's "awesome" is that not a soul on this thread has asked you a single clarifying question...
WHY do you want one and WHAT do you want to do with it?
http://confreaks.net/system/assets/datas/234/original/20-nov-2009-09-30-towards-a-ruby-compiler-caleb-clausen-small.mp4?1284086243
* GitHub - coatl/ocelot: Caleb Clausen's type-inducting ruby-to-c converter
Caleb's work into this is very interesting, though I'll admit there's
lots more to be done.
The more I think about it, the more I think that newer JVM languages
like scala and clojure *are* like compiled Ruby. They allow for REPL,
yet are compiled. The only annoying thing about them is the extra
startup time (also there in jruby, btw), and the fact that you have to
add type information, but they may scratch your itch.
-r
···
--
Posted via http://www.ruby-forum.com/\.
Perhaps the most straightforward answer for wanting a Hiphop or
Starkiller-like compiler is FOR SPEED! For example, you're a company on the
scale of Facebook who has written a large web site in a dynamic language and
suddenly realize you could be saving a lot of money on servers if your app
ran a lot faster. Source translation to C++ is a potential way to go
I don't think that applies to anyone who uses Ruby, though. Maybe Twitter...
···
On Fri, Oct 1, 2010 at 7:52 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
What's "awesome" is that not a soul on this thread has asked you a single
clarifying question...WHY do you want one and WHAT do you want to do with it?
--
Tony Arcieri
Medioh! A Kudelski Brand
The closest we have is the Rubinius Project:
It just hit release 1.1.0 and is looking really good. Most of the standard library is in Ruby while certain portions are written in C++. The goal is to move *more* of it to Ruby as the compiler and JIT get more intelligent.
cr
···
On Oct 1, 2010, at 11:23 AM, Luc wrote:
Hi all.
This might be slightly off-topic but something interesting would be to
look at a canonical Ruby interpreter written in Ruby, in the lisp /
scheme fashion.I would be interested in knowing whether someone has done that
already.
I would have appreciated a context aware citation, e.g. including my
"correct answer".
Thank you for your comprehension.
R.
···
On Fri, Oct 1, 2010 at 6:56 PM, Tony Arcieri <tony.arcieri@medioh.com> wrote:
Short answer: You cant
It's possible, although many language features can't be supported, most
notably eval.
Well, I would disagree slightly. Not impossible, just dang hard to
implement, give what appears to me to be this odd gulf between languages
as being either "statically compiled and typed or not" (though a few
exceptions exist. bytecode emitters and the play framework come to
mind, as well as scala/clojure, so...we're getting there...).
-r
···
--
Posted via http://www.ruby-forum.com/\.
I do not think you have to add type information in Clojure, you can,
but the beauty of this is that this is only a last resource in case
performance is not good enough.
Cheers
Robert
···
On Sat, Oct 2, 2010 at 3:29 PM, Roger Pack <rogerpack2005@gmail.com> wrote:
startup time (also there in jruby, btw), and the fact that you have to
add type information, but they may scratch your itch.
--
The best way to predict the future is to invent it.
-- Alan Kay
Seriously, I believe these questions are not worth asking.
Then why do you bother with this mailing list? You might as well unsubscribe now.
It is 100% possible in both principle and in practice to convert Ruby code into another language where the output performs the same functions as the original code.
I know. I've done it. Twice. See ruby2c for one such example. There is another, zenobfuscate, (unreleased) that translates ruby to ruby c internals so that you can compile a ruby c extension and ship a binary instead of raw source. This may be what the OP wanted, but since nobody bothered to ask before answering (in volumes), it looks like they were chased off.
However, the output will have nothing to do with Ruby in any way.
This is entirely false and I see absolutely no justification in the rest of your mail for such a claim.
···
On Oct 2, 2010, at 05:36 , Ammar Ali wrote:
My point was that none of your speculation matters in the absence of clarifying questions to the OP.
···
On Oct 4, 2010, at 17:02 , Tony Arcieri wrote:
On Fri, Oct 1, 2010 at 7:52 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
What's "awesome" is that not a soul on this thread has asked you a single
clarifying question...WHY do you want one and WHAT do you want to do with it?
Perhaps [... lots of speculation ...]