Objective C backend for Ruby?

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).

Just wondering.

···

Jim Hranicky, Senior SysAdmin UF/CISE Department |
E314D CSE Building Phone (352) 392-1499 |
jfh@cise.ufl.edu http://www.cise.ufl.edu/~jfh |


You’d have a heck of a time with continuations, unfortunately.
Otherwise it should be reasonably doable.

···

At 10:35 PM +0900 7/19/02, James F.Hranicky wrote:

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I can
find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

In article <a05111b05b95de4b58e30@[63.120.19.221]>,

···

Dan Sugalski dan@sidhe.org wrote:

At 10:35 PM +0900 7/19/02, James F.Hranicky wrote:

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).

You’d have a heck of a time with continuations, unfortunately.
Otherwise it should be reasonably doable.

                                    Dan

Well, in the current Ruby implementation continuations are implemented
with C code, why couldn’t they be implemented in ObjectiveC?

Phil

I don’t think so. If you find it, then please post the URL. The Ruby
bindings to Tk are almost identical to the Perl bindings. Knowing this, you
should buy the Perl/Tk Pocket Reference ($10) and learn to translate the Perl
commands, options, etc. into Ruby. It isn’t too hard and is recommended in
Chapter 15 of the Programming Ruby book.

···

On Friday 19 July 2002 11:18 am, Maggie Xiao wrote:

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I can
find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to do
to get continuations going with what’s essentially a C environment.
It’s… interesting)

Certainly the interpreter could be done in Objective C. That part’s
no big deal since objective C’s pretty much a superset of C so ruby
right now is more or less an Objective C app.

···

At 5:22 AM +0900 7/21/02, Phil Tomson wrote:

In article <a05111b05b95de4b58e30@[63.120.19.221]>,
Dan Sugalski dan@sidhe.org wrote:

At 10:35 PM +0900 7/19/02, James F.Hranicky wrote:

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).

You’d have a heck of a time with continuations, unfortunately.
Otherwise it should be reasonably doable.

Well, in the current Ruby implementation continuations are implemented
with C code, why couldn’t they be implemented in ObjectiveC?


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

Thanks, I think I can learn how to translate the command into ruby/tk,but I
would like to know the relation among different classes.Do you mean the
per/tk reference include it?

···

----- Original Message -----
From: “Albert Wagner” alwagner@tcac.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 10:29 AM
Subject: Re: Is there any English version of Ruby/tk class documentation
like this ?

On Friday 19 July 2002 11:18 am, Maggie Xiao wrote:

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I
can

find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

I don’t think so. If you find it, then please post the URL. The Ruby
bindings to Tk are almost identical to the Perl bindings. Knowing this,
you
should buy the Perl/Tk Pocket Reference ($10) and learn to translate the
Perl
commands, options, etc. into Ruby. It isn’t too hard and is recommended
in
Chapter 15 of the Programming Ruby book.

like this ?

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I
can

find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

I don’t think so. If you find it, then please post the URL. The Ruby
bindings to Tk are almost identical to the Perl bindings. Knowing this,
you
should buy the Perl/Tk Pocket Reference ($10) and learn to translate the
Perl
commands, options, etc. into Ruby. It isn’t too hard and is recommended
in
Chapter 15 of the Programming Ruby book.

I wonder if you could use RDoc on the Ruby/Tk
code. (At least to expose the structure.)

Just a thought. I’ve never tried it.

Hal

···

----- Original Message -----
From: “Albert Wagner” alwagner@tcac.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 11:29 AM
Subject: Re: Is there any English version of Ruby/tk class documentation

On Friday 19 July 2002 11:18 am, Maggie Xiao wrote:

In article <a05111b10b95f7847af7a@[63.120.19.221]>,

···

Dan Sugalski dan@sidhe.org wrote:

At 5:22 AM +0900 7/21/02, Phil Tomson wrote:

In article <a05111b05b95de4b58e30@[63.120.19.221]>,
Dan Sugalski dan@sidhe.org wrote:

At 10:35 PM +0900 7/19/02, James F.Hranicky wrote:

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).

You’d have a heck of a time with continuations, unfortunately.
Otherwise it should be reasonably doable.

Well, in the current Ruby implementation continuations are implemented
with C code, why couldn’t they be implemented in ObjectiveC?

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to do
to get continuations going with what’s essentially a C environment.
It’s… interesting)

Certainly the interpreter could be done in Objective C. That part’s
no big deal since objective C’s pretty much a superset of C so ruby
right now is more or less an Objective C app.

I’m thinking of the translator aspect as well (Ruby => Objective C). But
I suppose we’d have to muck around with the Objective C runtime to get
continuations to work… I dunno how hard that would be, but it seems like
it might be doable…

Phil

If I might throw out a suggestion, if its not broke, don’t fix it.
Ruby’s written in C so its ALREADY written in Objective-C. Leave that
alone.

Ruby DOES need a better user interface. This is Objective-C’s
object-oriented strong suit. Focus your energy there, on where Ruby
is broken, not where its intact.

···

At 5:45 AM +0900 7/21/02, Dan Sugalski wrote:

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to do
to get continuations going with what’s essentially a C environment.
It’s… interesting)


Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

it looks to be only partial but (and undocumented):

http://www.eng.dmu.ac.uk/~hgs/ruby/ruby-1.6.7-rdocs/files/ext/tk/lib/tk_rb.html

also, which has now only occured to me, you could generate the rdocs
yourself.

~transami

···

On Fri, 2002-07-19 at 10:49, Maggie Xiao wrote:

Thanks, I think I can learn how to translate the command into ruby/tk,but I
would like to know the relation among different classes.Do you mean the
per/tk reference include it?
----- Original Message -----
From: “Albert Wagner” alwagner@tcac.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 10:29 AM
Subject: Re: Is there any English version of Ruby/tk class documentation
like this ?

On Friday 19 July 2002 11:18 am, Maggie Xiao wrote:

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I
can

find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

I don’t think so. If you find it, then please post the URL. The Ruby
bindings to Tk are almost identical to the Perl bindings. Knowing this,
you
should buy the Perl/Tk Pocket Reference ($10) and learn to translate the
Perl
commands, options, etc. into Ruby. It isn’t too hard and is recommended
in
Chapter 15 of the Programming Ruby book.


~transami

(") dobee dobee do…
\v/
^ ^

Thanks, I think I can learn how to translate the command into ruby/tk,but I
would like to know the relation among different classes.Do you mean the
per/tk reference include it?

If you want to say the inheritence hierarchy then you can use Objectspace
to find it.

This must give something like this (if you just make a 'require "tk"')
Must be verified (modules are in ())

* TkBindTag
    * TkBindTagAll (TkBindCore Kernel)

* TkKernel
    * TkObject (TkBindCore TkTreatFont Tk TkCore TkComm Kernel)
        * TkWindow
            * TkFrame
            * TkLabel
                * TkButton
                    * TkRadioButton
                        * TkCheckButton
                * TkMenubutton
                    * TkOptionMenubutton
                * TkMessage
            * TkMenu (TkTreatMenuEntryFont TkTreatItemFont)
                * TkMenuClone
                * TkOptionMenubutton::OptionMenu
                * TkSysMenu_Apple (TkSystemMenu)
                * TkSysMenu_Help (TkSystemMenu)
                * TkSysMenu_System (TkSystemMenu)
            * TkRoot (Tk::Wm)
            * TkScale
            * TkScrollbar
            * TkTextWin
                * TkListbox (Tk::Scrollable TkTreatListItemFont TkTreatItemFont)
            * TkToplevel (Tk::Wm)

Guy Decoux

Thanks everyone who give me the information about it.They are really
helpful.Have a good weekend.

···

----- Original Message -----
From: “Hal E. Fulton” hal9000@hypermetrics.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 1:11 PM
Subject: Re: Is there any English version of Ruby/tk class documentation
like this ?

----- Original Message -----
From: “Albert Wagner” alwagner@tcac.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 11:29 AM
Subject: Re: Is there any English version of Ruby/tk class documentation
like this ?

On Friday 19 July 2002 11:18 am, Maggie Xiao wrote:

Hi,

I need some Ruby/tk documentation, and I find a website,
http://www2.pos.to/~tosh/ruby/rdtool/rubytk.html
but unfortunately, it is a Japanese website.Anyone can tell me where I
can

find a documentation like this one? I’d like to know the detailed
introduction of every class ,such as super class,class method,instance
method.etc. Thanks for any information .

Maggie

I don’t think so. If you find it, then please post the URL. The Ruby
bindings to Tk are almost identical to the Perl bindings. Knowing this,
you
should buy the Perl/Tk Pocket Reference ($10) and learn to translate the
Perl
commands, options, etc. into Ruby. It isn’t too hard and is recommended
in
Chapter 15 of the Programming Ruby book.

I wonder if you could use RDoc on the Ruby/Tk
code. (At least to expose the structure.)

Just a thought. I’ve never tried it.

Hal

Continuations are a massive pain to do in a language that doesn’t
have them. Doing continuations means messing around with the system
stack, and to do it well you really want to treat the stack as a tree
of semi-independent frames rather than a single chunk of contiguous
memory as most C-style languages do.

There are tricks you can play, for example you can translate all
function calls into a continuation-passing style call and do Evil
Things with setjmp/longjmp, but generally those tricks are, well,
evil. Plus they don’t Play Well with others. (Though, arguably,
anytime you mix languages with continuations with languages without
continuations you can run into trouble, but it’s not tough to make
those bad spots edge cases)

···

At 6:42 AM +0900 7/21/02, Phil Tomson wrote:

In article <a05111b10b95f7847af7a@[63.120.19.221]>,
Dan Sugalski dan@sidhe.org wrote:

At 5:22 AM +0900 7/21/02, Phil Tomson wrote:

In article <a05111b05b95de4b58e30@[63.120.19.221]>,
Dan Sugalski dan@sidhe.org wrote:

At 10:35 PM +0900 7/19/02, James F.Hranicky wrote:

While people are kicking around ideas for new backends for Ruby,
does anyone think that a backend could be written for Ruby that
uses the Objective C (GnuStep, Cocoa) runtime libraries? Or even
just a translator from Ruby to ObjC ?

Seems that the languages are simliar in many respects, and it seems
like ObjC, being a superset of C, would make a good backend if it’s
possible (threads, performance, etc).

You’d have a heck of a time with continuations, unfortunately.
Otherwise it should be reasonably doable.

Well, in the current Ruby implementation continuations are implemented
with C code, why couldn’t they be implemented in ObjectiveC?

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to do
to get continuations going with what’s essentially a C environment.
It’s… interesting)

Certainly the interpreter could be done in Objective C. That part’s
no big deal since objective C’s pretty much a superset of C so ruby
right now is more or less an Objective C app.

I’m thinking of the translator aspect as well (Ruby => Objective C). But
I suppose we’d have to muck around with the Objective C runtime to get
continuations to work… I dunno how hard that would be, but it seems like
it might be doable…


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to
do to get continuations going with what’s essentially a C
environment. It’s… interesting)

If I might throw out a suggestion, if its not broke, don’t fix it.
Ruby’s written in C so its ALREADY written in Objective-C. Leave
that alone.

I’d agree. If folks want to toss the interpreter, you might as well
go all out and generate machine code directly. It turns out not to be
nearly as tricky to do semi-portably as most people think. (Well, at
least as much as I thought)

Ruby DOES need a better user interface. This is Objective-C’s
object-oriented strong suit. Focus your energy there, on where Ruby
is broken, not where its intact.

Yep. I expect Ruby would mix very well with Cocoa on OS X–I know
perl does with the CamelBones library, and for Cocoa-ish things Ruby
and Perl are pretty much equivalent in semantics. (Ruby’s got an edge
here in OO features) There’s a certain nifty feeling to laying out
your GUI with Interface Builder and realizing the biggest difference
on the app code end is the method calls look like object->method
rather than [object method]…

···

At 6:04 PM -0400 7/20/02, Brad Cox wrote:

At 5:45 AM +0900 7/21/02, Dan Sugalski wrote:

Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

Must be verified (modules are in ())

Bad, bad I've forgotten some classes

    * TclTkIp (Kernel)
    * TkComm::Event (Kernel)
    * TkVariable (Tk TkCore TkComm Kernel)
        * TkVarAccess

* TkBindTag

Guy Decoux

Continuations are a massive pain to do in a language that doesn’t
have them. Doing continuations means messing around with the system
stack, and to do it well you really want to treat the stack as a
tree of semi-independent frames rather than a single chunk of
contiguous memory as most C-style languages do.

I spent years on this problem in the middle 80’s (search for
TaskMaster on my website). I mainly proved that is possible to add
continuations, exceptions, garbage collection, what have you, to C,
but its almost impossible to do any of these things well, certainly
without sacrificing the things C is good at.

But why bother? Ruby’s not C and it has continuations already.
There’s absolutely no need to plow that furrow again. Spend the time
on something useful!

···

At 7:20 AM +0900 7/21/02, Dan Sugalski wrote:

There are tricks you can play, for example you can translate all
function calls into a continuation-passing style call and do Evil
Things with setjmp/longjmp, but generally those tricks are, well,
evil. Plus they don’t Play Well with others. (Though, arguably,
anytime you mix languages with continuations with languages without
continuations you can run into trouble, but it’s not tough to make
those bad spots edge cases)


Brad Cox, PhD; bcox@virtualschool.edu 703 361 4751
o For industrial age goods there were checks and credit cards.
For everything else there is http://virtualschool.edu/mybank
o Interactive Learning Environment http://virtualschool.edu/ile
o Java Web Application Architecture: http://virtualschool.edu/jwaa

In article <a05111b13b95f91899af1@[63.120.19.221]>,

···

Dan Sugalski dan@sidhe.org wrote:

At 6:04 PM -0400 7/20/02, Brad Cox wrote:

At 5:45 AM +0900 7/21/02, Dan Sugalski wrote:

I was looking at the translator aspect, translating Ruby to
Objective-C. That was the part that was the real non-starter,
courtesy of continuations. (I’ve got a paper or two kicking around
about some of the interesting things that the Scheme folks had to
do to get continuations going with what’s essentially a C
environment. It’s… interesting)

If I might throw out a suggestion, if its not broke, don’t fix it.
Ruby’s written in C so its ALREADY written in Objective-C. Leave
that alone.

I’d agree. If folks want to toss the interpreter, you might as well
go all out and generate machine code directly. It turns out not to be
nearly as tricky to do semi-portably as most people think. (Well, at
least as much as I thought)

OR, target Parrot which we certainly hope will offer some speed ehancement
over the current Ruby implementation…

Phil

Thanks, they are really helpful. And I’d like to ask a simple question if
you don’t mind. How to use Objectspace to find it? Thanks.

···

----- Original Message -----
From: “ts” decoux@moulon.inra.fr
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org; ruby-talk@ruby-lang.org
Sent: Friday, July 19, 2002 11:28 AM
Subject: Re: Is there any English version of Ruby/tk class documentation
like this ?

Must be verified (modules are in ())

Bad, bad I’ve forgotten some classes

* TclTkIp   (Kernel)
* TkComm::Event     (Kernel)
* TkVariable        (Tk TkCore TkComm Kernel)
    * TkVarAccess
  • TkBindTag

Guy Decoux

Continuations are a massive pain to do in a language that doesn’t
have them. Doing continuations means messing around with the system
stack, and to do it well you really want to treat the stack as a
tree of semi-independent frames rather than a single chunk of
contiguous memory as most C-style languages do.

I spent years on this problem in the middle 80’s (search for
TaskMaster on my website). I mainly proved that is possible to add
continuations, exceptions, garbage collection, what have you, to C,
but its almost impossible to do any of these things well, certainly
without sacrificing the things C is good at.

Oh, absolutely. I’m reasonably aware of the problems involved, which
is why I don’t think it’s worthwhile. C’s a lousy target for this
sort of thing. Not that the native machine language is generally much
better as a target as most chips these days had C in mind for their
design, but at least you throw away any pretense that the language’s
going to give you any help.

But why bother?

Speed, mainly. Going from an interpreted to a compiled form gives a
number of opportunities to remove overhead. Walking optrees has some
expense involved–depending on how complex the operation is, how much
optimization you do, and the CPU architecture, you can see a speedup
somewhere between 1.1 and 40 times going compiled.

Ruby’s not C and it has continuations already. There’s absolutely no
need to plow that furrow again. Spend the time on something useful!

Right, but Ruby’s interpreted right now. Compilation brings a number
of benefits, though there are potentially some tradeoffs involved as
well.

···

At 6:49 PM -0400 7/20/02, Brad Cox wrote:

At 7:20 AM +0900 7/21/02, Dan Sugalski wrote:

Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk