Interest in Boost::Ruby

I'd like to build a CSS renderer in modern C++ as an enthusist's
    pursuit. I don't want to get bogged down in huge build systems,
    or many different IDEs.

    I'd like to make development rapid by using a scripting
    language where I can. I want it to be Ruby. I'm adopting Ruby as
    a build system for C++ as noted in another thread.
    
    It would be nice to script complicated algrothims in Ruby,
    before fixing them in C++. I'd like to work on making objects
    accessible to Ruby as I go along.

    I know that Ruby can communicate with C++ using SWIG, but I'm
    wondering if there isn't anything more explicit. Something that
    will bind tighter to Ruby. The Boost libraries favor Python due
    to Boost::Python. Is there something similar, or is there
    interest in something similar?

        http://www.boost.org/libs/python/doc/

···

--
Alan Gutierrez - alan@engrm.com
    - http://engrm.com/blogometer/index.html
    - http://engrm.com/blogometer/rss.2.0.xml

Dunno about Boost::Ruby, but why not quickly write the whole thing in
Ruby? It would at least give you a chance to quickly prototype the
application and try out different ideas.

Then, if you want, rewrite the app in C++.

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

    I'd like to build a CSS renderer in modern C++ as an enthusist's
    pursuit. I don't want to get bogged down in huge build systems,
    or many different IDEs.

    I'd like to make development rapid by using a scripting
    language where I can. I want it to be Ruby. I'm adopting Ruby as
    a build system for C++ as noted in another thread.

    It would be nice to script complicated algrothims in Ruby,
    before fixing them in C++. I'd like to work on making objects
    accessible to Ruby as I go along.

    I know that Ruby can communicate with C++ using SWIG, but I'm
    wondering if there isn't anything more explicit. Something that
    will bind tighter to Ruby. The Boost libraries favor Python due
    to Boost::Python. Is there something similar, or is there
    interest in something similar?

        Boost.Python - 1.84.0

Just for what it's worth, after RubyConf, I hope to be working on a
CSS engine. The purpose of this engine will be very limited --
applying CSS to SVG documents for proper rendering in PDF documents,
but it will be written entirely in Ruby.

-austin

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

    I'd like to build a CSS renderer in modern C++ as an enthusist's
    pursuit. I don't want to get bogged down in huge build systems,
    or many different IDEs.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

In article <20050930235907.GA5084@maribor.izzy.net>,

···

Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

   I'd like to build a CSS renderer in modern C++ as an enthusist's
   pursuit. I don't want to get bogged down in huge build systems,
   or many different IDEs.

   I'd like to make development rapid by using a scripting
   language where I can. I want it to be Ruby. I'm adopting Ruby as
   a build system for C++ as noted in another thread.
   
   It would be nice to script complicated algrothims in Ruby,
   before fixing them in C++. I'd like to work on making objects
   accessible to Ruby as I go along.

   I know that Ruby can communicate with C++ using SWIG, but I'm
   wondering if there isn't anything more explicit. Something that
   will bind tighter to Ruby. The Boost libraries favor Python due
   to Boost::Python. Is there something similar, or is there
   interest in something similar?

       Boost.Python - 1.84.0

I would definitely be interested in something like this, although, how
different would it be from Inline::C/C++?

Phil

Alan Gutierrez wrote:

   I know that Ruby can communicate with C++ using SWIG, but I'm
   wondering if there isn't anything more explicit. Something that
   will bind tighter to Ruby. The Boost libraries favor Python due
   to Boost::Python. Is there something similar, or is there
   interest in something similar?

       Boost.Python - 1.84.0

I have no idea how Boost reflects C++ members into Python members, but
Boosties are the C++ reflection experts so I'm sure they beat a way out of
C++'s endlessly complex template system.

Bonding raw Ruby to raw C++ is much much easier than bonding Python to it.
(Or Perl, or Lua, while we are on the topic. I have worked with all four.)

I wrote an extensive project using Ruby as the scripting language for an
OpenGL renderer, and I tossed it on the web somewhere, but I forget where.

Eric Hodel is probably the best C language bonding expert. Here's one of his
blogs showing "Ruby written in C":

http://www.livejournal.com/users/drbrain/2005/05/03/

The best thing I have done with the VALUE object is very simple: I wrap it
in a C++ class that exposes the functions taking a VALUE as simple methods,
overloaded operators, etc. Very simple, and I don't pretend it's a C++
class. It makes coding very fast.

···

--
  Phlip
  greencheese.org <-- NOT a blog!!!

* Joe Van Dyk <joevandyk@gmail.com> [2005-09-30 20:10]:

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

> I know that Ruby can communicate with C++ using SWIG, but I'm
> wondering if there isn't anything more explicit. Something that
> will bind tighter to Ruby. The Boost libraries favor Python due
> to Boost::Python. Is there something similar, or is there
> interest in something similar?

> Boost.Python - 1.84.0

Dunno about Boost::Ruby, but why not quickly write the whole thing in
Ruby? It would at least give you a chance to quickly prototype the
application and try out different ideas.

Then, if you want, rewrite the app in C++.

    I am going to want to work with C++ from the start. I'd like to
    know if there is a modern C++ specific library for binding Ruby,
    or if I should create one.

--
Alan Gutierrez - alan@engrm.com
    - http://engrm.com/blogometer/index.html
    - http://engrm.com/blogometer/rss.2.0.xml

ruby2ruby will let you call to_c or to_ruby on your methods and they'll output
said code.

I have not used it, so I have no real clue if it's what you're looking for,
but it might help your cause.

http://blog.zenspider.com/archives/2005/02/rubytoruby.html

* Austin Ziegler <halostatue@gmail.com> [2005-09-30 21:41]:

> I'd like to build a CSS renderer in modern C++ as an enthusist's
> pursuit. I don't want to get bogged down in huge build systems,
> or many different IDEs.

Just for what it's worth, after RubyConf, I hope to be working on a
CSS engine. The purpose of this engine will be very limited --
applying CSS to SVG documents for proper rendering in PDF documents,
but it will be written entirely in Ruby.

    This is a pet of mine. It's supposed to be a fun way to learn
    some new things, and a hopefully fun enough that people get
    others interested.
    
    It's nice to have a clean specification like CSS to implement,
    so I can focus on the implementation, rather than the interface.

    My plan would be to create UI primitives in C++ first, and make
    then available to Ruby. This rather than adopting Qt or Tk
    similiar, since it would have a lot of things I don't need.

    It would be great if there was a way to combine efforts.

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

* Phil Tomson <ptkwt@aracnet.com> [2005-09-30 21:52]:

In article <20050930235907.GA5084@maribor.izzy.net>,
> I'd like to build a CSS renderer in modern C++ as an enthusist's
> pursuit. I don't want to get bogged down in huge build systems,
> or many different IDEs.
>
> I'd like to make development rapid by using a scripting
> language where I can. I want it to be Ruby. I'm adopting Ruby as
> a build system for C++ as noted in another thread.
>
> It would be nice to script complicated algrothims in Ruby,
> before fixing them in C++. I'd like to work on making objects
> accessible to Ruby as I go along.
>
> I know that Ruby can communicate with C++ using SWIG, but I'm
> wondering if there isn't anything more explicit. Something that
> will bind tighter to Ruby. The Boost libraries favor Python due
> to Boost::Python. Is there something similar, or is there
> interest in something similar?
>
> Boost.Python - 1.84.0

I would definitely be interested in something like this, although, how
different would it be from Inline::C/C++?

    I'll have to look into Inline::C/C++ and get back to you. But,
    if it is like an inline assembler, like the Perl module of the
    same name, I want to keep C++ independent.
    
    I don't see the C++ as being an inline speedup of a Ruby method,
    but a bridge between two systems, and one that permits the
    programmer to wander back and forth across that bridge, using
    Ruby or modern C++ when it suits them.

    I want to program in modern C++. The Advanced C++ series looks
    like fun, so I'm going to approach this project with those
    concepts. I'm not looking to use C++ sparingly, rather I want to
    use the full kit as intended.

    Use Case
    
    For a CSS renderer, I don't want to deal directly with expat or
    worse, write my own C++ xml parser. I'd rather use Ruby to parse
    an XML file, and have it feed events to a modern C++ builder
    that would create the DOM, which would be implemented in modern C++.

    On a desktop, Ruby can be the XML parser, on a cell phone, maybe
    a binary DOM format is stored to a database.
    
    Then, I'd like to prototype a BIDI algorithm in as little time
    as possible. I'd like to use Ruby for that algorithm, so the DOM
    is going to have to send events to Ruby when the user edits a form.

    This might have been too much of an answer. :^\

···

Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

Phlip wrote:

The best thing I have done with the VALUE object is very simple: I wrap it
in a C++ class that exposes the functions taking a VALUE as simple
methods, overloaded operators, etc. Very simple, and I don't pretend it's
a C++ class. It makes coding very fast.

Here's that wrapper for Ruby's VALUE object:

        class
    rbValue
    {
    public:

    rbValue(VALUE nuV = Qnil):
            v(nuV)
        {}

    rbValue(char const * gv):
            v(Qnil)
        {
        assert(gv);
        assert('$' == gv[0]); // documentation sez this is optional. We
don't agree
        v = rb_gv_get(gv);
        }

        operator VALUE() const { return v; }
        rbValue &operator =(VALUE nuV) { v = nuV; return *this; }

        rbValue
    fetch(char const * tag)
        {
        return funcall("fetch", 2, rb_str_new2(tag), Qnil);
        }

        rbValue
    fetch(int idx)
        {
        return funcall("fetch", 2, INT2FIX(idx), Qnil);
        }

        rbValue
    fetch(size_t idx)
        {
        return funcall("fetch", 2, INT2FIX(idx), Qnil);
        }

        VALUE *
    getPtr()
        {
        assert(T_ARRAY == TYPE(v));
        return RARRAY(v)->ptr;
        }

        long
    getLen()
        {
        assert(T_ARRAY == TYPE(v));
        return RARRAY(v)->len;
        }

        rbValue
    getAt(long idx)
        {
        assert(idx < getLen());
        return RARRAY(v)->ptr[idx];
        }

        rbValue
    operator(long idx)
        {
        return getAt(idx);
        }

        bool isNil() { return Qnil == v; }

        double to_f()
            {
            assert(T_FLOAT == TYPE(v) || T_FIXNUM == TYPE(v));
            return NUM2DBL(v);
            }

        char const * to_s()
            {
            assert(T_STRING == TYPE(v));
            return STR2CSTR(v);
            }

        rbValue
    funcall (
            char const * method,
            int argc = 0,
            VALUE arg1 = Qnil,
            VALUE arg2 = Qnil,
            VALUE arg3 = Qnil
            )
        {
        return rb_funcall(v, rb_intern(method), argc, arg1, arg2, arg3);
        }

        rbValue
    iv_get(char const * member)
        {
        VALUE iv = rb_iv_get(v, member);
        return iv;
        }

        void
    iv_set(char const * member, VALUE datum)
        {
        rb_iv_set(v, member, datum);
        }

        void
    iv_set(char const * member, int datum)
        {
        iv_set(member, INT2FIX(datum));
        }

    private:
        VALUE v;

    }; // a smart wrapper for the Ruby VALUE type

Call its members like this:

        void
    push(rbValue xyzIn)
    {
        rbValue str = xyzIn.funcall("inspect");
        OutputDebugStringA(str.to_s());
        OutputDebugStringA("\n");
    }

Google for that code to find its project.

Converting it into a snarl of Boostoidal templates is left as an exercise
for the obsessed.

···

--
  Phlip
greencheese.org <-- NOT a blog!!!

Um... FYI. That code is a pure/1:1 translation from a ruby version of factorial to a C version of the same thing, using ruby-C internals only. It is even slightly slower than running the ruby version. It is only meant as a proof-of-concept (towards an automatic obfuscator).

···

On Sep 30, 2005, at 10:41 PM, Phlip wrote:

Eric Hodel is probably the best C language bonding expert. Here's one of his
blogs showing "Ruby written in C":

http://www.livejournal.com/users/drbrain/2005/05/03/

--
ryand-ruby@zenspider.com - Seattle.rb - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c

Alan Gutierrez wrote:

    I am going to want to work with C++ from the start. I'd like to
    know if there is a modern C++ specific library for binding Ruby,
    or if I should create one.

I don't know of one either, but I'd be interested in helping

* Kevin Brown <blargity@gmail.com> [2005-09-30 21:52]:

ruby2ruby will let you call to_c or to_ruby on your methods and
they'll output said code.

I have not used it, so I have no real clue if it's what you're looking for,
but it might help your cause.

http://blog.zenspider.com/archives/2005/02/rubytoruby.html

    Using Ruby to generate modern C++ interfaces is cool. I didn't
    know it was that easy to parse Ruby.
    
    (Too bad it's not as easy to part C++.

        Maybe I can use Ruby as an IDL and have Ruby generate C,
        Ruby, Python, Perl 6, etc.
        
        Or the idea of prototyping in Ruby, then going to straight C
        becomes very powerful if this can be extended to full Ruby
        classes.)

···

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

* Austin Ziegler <halostatue@gmail.com> [2005-09-30 21:41]:

I'd like to build a CSS renderer in modern C++ as an enthusist's
pursuit. I don't want to get bogged down in huge build systems, or
many different IDEs.

Just for what it's worth, after RubyConf, I hope to be working on a
CSS engine. The purpose of this engine will be very limited --
applying CSS to SVG documents for proper rendering in PDF documents,
but it will be written entirely in Ruby.

This is a pet of mine. It's supposed to be a fun way to learn some new
things, and a hopefully fun enough that people get others interested.

Oh, I'm not in the least trying to discourage you from doing this. I'm
just also pointing out that I will be doing a core CSS *engine* in Ruby
intended for PDF output.

It's nice to have a clean specification like CSS to implement, so I
can focus on the implementation, rather than the interface.

Heh, um. CSS is most certainly *not* a clean specification. It's
implementable, sure, but there are certainly things that I will be
ignoring in the spec -- it's a right mess, that spec.

My plan would be to create UI primitives in C++ first, and make then
available to Ruby. This rather than adopting Qt or Tk similiar, since
it would have a lot of things I don't need.

It would be great if there was a way to combine efforts.

Well, the *main* problem is that the goal of my project(s) require a
pure Ruby implementation -- I do C/C++ hacking for a living and don't
want to hack at that on my spare time if I can help it. Additionally, it
is my belief that at some point Ruby's speed will catch up to or exceed
other scripting languages that it isn't really important to have C
extensions for certain things. Finally, doing it in Ruby gives me the
greatest portability -- it will run on any platform that Ruby itself
does.

-austin

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

> On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

* Phlip <phlipcpp@yahoo.com> [2005-10-01 01:52]:

Phlip wrote:

> The best thing I have done with the VALUE object is very simple: I wrap it
> in a C++ class that exposes the functions taking a VALUE as simple
> methods, overloaded operators, etc. Very simple, and I don't pretend it's
> a C++ class. It makes coding very fast.

Here's that wrapper for Ruby's VALUE object:

    [code]

Google for that code to find its project.

Converting it into a snarl of Boostoidal templates is left as an
exercise for the obsessed.

    Thank you for the code. I intend to start with the simplest
    thing that works and go from there, rather than, say, starting
    from Boost::Python and working backwards.

···

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

* Ryan Davis <ryand-ruby@zenspider.com> [2005-10-04 19:32]:

>Eric Hodel is probably the best C language bonding expert. Here's
>one of his
>blogs showing "Ruby written in C":
>
>http://www.livejournal.com/users/drbrain/2005/05/03/

Um... FYI. That code is a pure/1:1 translation from a ruby version of
factorial to a C version of the same thing, using ruby-C internals
only. It is even slightly slower than running the ruby version. It is
only meant as a proof-of-concept (towards an automatic obfuscator).

    I saw that. I'm now looking into a few existing C++ bind
    libraries for C++ to other langauges, and will emulate those.

···

On Sep 30, 2005, at 10:41 PM, Phlip wrote:

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

* Alan Chen <Digikata@gmail.com> [2005-09-30 22:06]:

Alan Gutierrez wrote:
> I am going to want to work with C++ from the start. I'd like to
> know if there is a modern C++ specific library for binding Ruby,
> or if I should create one.

I don't know of one either, but I'd be interested in helping

    Cool. There's interest.

···

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

* Austin Ziegler <halostatue@gmail.com> [2005-09-30 23:07]:

> * Austin Ziegler <halostatue@gmail.com> [2005-09-30 21:41]:
>>> I'd like to build a CSS renderer in modern C++ as an enthusist's
>>> pursuit. I don't want to get bogged down in huge build systems, or
>>> many different IDEs.
>> Just for what it's worth, after RubyConf, I hope to be working on a
>> CSS engine. The purpose of this engine will be very limited --
>> applying CSS to SVG documents for proper rendering in PDF documents,
>> but it will be written entirely in Ruby.

> This is a pet of mine. It's supposed to be a fun way to learn
> some new things, and a hopefully fun enough that people get
> others interested.

Oh, I'm not in the least trying to discourage you from doing this.
I'm just also pointing out that I will be doing a core CSS
*engine* in Ruby intended for PDF output.

    I didn't think you were trying to discourage me.

> My plan would be to create UI primitives in C++ first, and make then
> available to Ruby. This rather than adopting Qt or Tk similiar, since
> it would have a lot of things I don't need.

> It would be great if there was a way to combine efforts.

Well, the *main* problem is that the goal of my project(s) require
a pure Ruby implementation -- I do C/C++ hacking for a living and
don't want to hack at that on my spare time if I can help it.

    I'm really only interested in modern C++, things like MPL. I'm
    not interested industry C/C++. C++ is a language fetish, not
    a desire to be boring in any way.

    I'm hoping there are some Ruby programmers that share the same
    interests. I don't have strong opinions on either language, I'm
    really only interested in the language concepts.

Additionally, it is my belief that at some point Ruby's speed will
catch up to or exceed other scripting languages that it isn't
really important to have C extensions for certain things. Finally,
doing it in Ruby gives me the greatest portability -- it will run
on any platform that Ruby itself does.

    The portability of Ruby is very nice. It's one of the things
    that appeals to me about Ruby.

    I'm just saying, if there's a way to collaborate, I'm all for it.

    Cheers.

···

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:
> > On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/

> * Austin Ziegler <halostatue@gmail.com> [2005-09-30 21:41]:
> >
>>> I'd like to build a CSS renderer in modern C++ as an enthusist's
>>> pursuit. I don't want to get bogged down in huge build systems, or
>>> many different IDEs.

Just to be sure I'm on the same page, by CSS renderer, you mean something that
renders HTML, using style information from a CSS file/sheet?

If yes, I'm interested and may try to help (to the extent I can). (I want
something that renders very quickly, and provides an easy interface from
another thingie (like a specialized editor widget) (I don't want to send the
data from the other thingie to a file to be opened by the CSS renderer, but
something much more direct--I'd rather send a pointer to a string containing
the HTML or something along those lines.)

Do you plan to render the CSS/HTML in a GUI widget type thingie, or somehow
just have console output (along the lines of lynx, links, ...)? (I'm looking
for a GUI widget.)

If you plan on a GUI widget, do you have a prebuilt one in mind? Which?

If I'm way off base, maybe you can clarify a little more what you have in
mind. (I see Austin's (?) reference to applying CSS to SVG documents in the
next paragraph--is that what you have in mind?)

>> Just for what it's worth, after RubyConf, I hope to be working on a
>> CSS engine. The purpose of this engine will be very limited --
>> applying CSS to SVG documents for proper rendering in PDF documents,
>> but it will be written entirely in Ruby.

Heh, um. CSS is most certainly *not* a clean specification. It's
implementable, sure, but there are certainly things that I will be
ignoring in the spec -- it's a right mess, that spec.

> My plan would be to create UI primitives in C++ first, and make then
> available to Ruby. This rather than adopting Qt or Tk similiar, since
> it would have a lot of things I don't need.

Hmm, I've tried C++ a few times, never made much progress, I think I'd prefer
something more Ruby like, although I'm only in the (temporarily interrupted)
process of learning Ruby.

Randy Kramer

···

On Friday 30 September 2005 11:06 pm, Austin Ziegler wrote:

On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:
> > On 9/30/05, Alan Gutierrez <alan-ruby-talk@engrm.com> wrote:

* Alan Chen <Digikata@gmail.com> [2005-09-30 22:06]:

Alan Gutierrez wrote:
> I am going to want to work with C++ from the start. I'd like to
> know if there is a modern C++ specific library for binding Ruby,
> or if I should create one.

I don't know of one either, but I'd be interested in helping

    Found a few exsiting projects, and some interest at Boost.

    I'm going to start blogging the project here...

    http://engrm.com/blogometer/categories/refresh/

    Wiki...

    http://engrm.com/wiki/Refresh

    And there's a mailing list, but probably not worth joining yet.

    And I'll post general Ruby questions here.

···

--
Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/