Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how can we make a ruby compiler

Reply
Thread Tools

how can we make a ruby compiler

 
 
Robin
Guest
Posts: n/a
 
      10-01-2010
how can we make a thing that compiles ruby into c++ source code?
does anyone want to help me make one....
-r

http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Robert Dober
Guest
Posts: n/a
 
      10-01-2010
On Fri, Oct 1, 2010 at 6:40 AM, Robin <(E-Mail Removed)> wrote:
> how can we make a thing that compiles ruby into c++ source code?
> does anyone want to help me make one....
> -r
>
> (E-Mail Removed)
>
>

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


--
The best way to predict the future is to invent it.
-- Alan Kay

 
Reply With Quote
 
 
 
 
Edmond Kachale
Guest
Posts: n/a
 
      10-01-2010
2010/10/1 Robert Dober <(E-Mail Removed)>

> On Fri, Oct 1, 2010 at 6:40 AM, Robin <(E-Mail Removed)> wrote:
> > how can we make a thing that compiles ruby into c++ source code?
> > does anyone want to help me make one....
> > -r
> >
> > (E-Mail Removed)
> >
> >

> Short answer: You cant
>


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, a=
nd
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 n=
ot
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

---
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=92t realize that
there is an alternative=85 which is just as good.." -- Kevin Scannell*

>
>
> --
> The best way to predict the future is to invent it.
> -- Alan Kay
>


 
Reply With Quote
 
Eleanor McHugh
Guest
Posts: n/a
 
      10-01-2010
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....


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
----
raise ArgumentError unless @reality.responds_to? :reason



 
Reply With Quote
 
Roger Pack
Guest
Posts: n/a
 
      10-01-2010
> 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/.

 
Reply With Quote
 
Luc
Guest
Posts: n/a
 
      10-01-2010
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.

 
Reply With Quote
 
Tony Arcieri
Guest
Posts: n/a
 
      10-01-2010
[Note: parts of this message were removed to make it a legal post.]

On Thu, Sep 30, 2010 at 11:00 PM, Robert Dober <(E-Mail Removed)>wrote:

> Short answer: You cant
>


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...=rep1&type=pdf

--
Tony Arcieri
Medioh! A Kudelski Brand

 
Reply With Quote
 
Chuck Remes
Guest
Posts: n/a
 
      10-01-2010

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.


The closest we have is the Rubinius Project:

http://rubini.us

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


 
Reply With Quote
 
Robert Dober
Guest
Posts: n/a
 
      10-01-2010
On Fri, Oct 1, 2010 at 6:56 PM, Tony Arcieri <(E-Mail Removed)> wrote:

I would have appreciated a context aware citation, e.g. including my
"correct answer".
Thank you for your comprehension.

R.

 
Reply With Quote
 
Roger Pack
Guest
Posts: n/a
 
      10-01-2010
>> 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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Compiler Error Message: The compiler failed with error code -1073741819 Ram ASP .Net 0 09-13-2005 09:52 AM
Compiler compiler with C++ as output Andrey Batyuck C++ 3 05-17-2004 08:17 PM
Can we use <compiler> tag to avoid RunTime Compiler error? Jack Wright ASP .Net 5 01-19-2004 04:36 PM
Compiler Error Message: The compiler failed with error code 128. Yan ASP .Net 0 07-21-2003 10:49 PM



Advertisments