C++ Exception compatibility idea

Hi,

I have a dream… no, it doesn’t involve little black kids and
little white kids, it involves Ruby (or some other scripting
language) and C++.

I’d love it if a language supported a feature whereby a C++
exception thrown in a C++ function is automatically processed and
caught in an enclosing Ruby raise/rescue block, and a Ruby
exception is caught and processed in a C++ try/catch block.

Obviously, I could create wrappers that do this at every language
boundary (which is easy) but it would be cool if this was built
into the interpreter, so it could be done without having to go
through any hassle.

I read on the Ruby wiki that it is being considered that Rite be
written (or Riten lol) in C++… could this be a neat little feature?

Thanks,
Asfand Yar

···


http://www.it-is-truth.org/

Asfand Yar Qazi wrote:

I’d love it if a language supported a feature whereby a C++ exception
thrown in a C++ function is automatically processed and caught in an
enclosing Ruby raise/rescue block, and a Ruby exception is caught and
processed in a C++ try/catch block.

Obviously, I could create wrappers that do this at every language
boundary (which is easy) but it would be cool if this was built into the
interpreter, so it could be done without having to go through any hassle.

I read on the Ruby wiki that it is being considered that Rite be written
(or Riten lol) in C++… could this be a neat little feature?

I think this might be accomplished with some kind of add-on wrapper
lib for C extensions. My knowledge is limited there, so don’t take me
too seriously.

As for implementing Rite in C++, I seem to remember Matz saying he would
not do such a thing. Where on the wiki did you see the comment?

Hal

In article 40A3E539.2010204@hypermetrics.com,

Asfand Yar Qazi wrote:

I read on the Ruby wiki that it is being considered that Rite be written
(or Riten lol) in C++… could this be a neat little feature?

As for implementing Rite in C++, I seem to remember Matz saying he would
not do such a thing. Where on the wiki did you see the comment?

I’ve been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C’s collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn’t be too hard
to build on existing code. Also, Objective C is supported by GCC.

…of course, the downside on Windows is that the Microsoft compilers
don’t support Objective C so all builds would have to be done under Cygwin
or MinGW. That may be a problem for some. There wouldn’t be any problems
on the Mac OSX platform, though :wink:

Phil

···

Hal Fulton hal9000@hypermetrics.com wrote:

But you have to ship also the Objective-C runtime lib, so you have either
the dependancy or it will blow up the interpreter in static builds.

Recently, I was looking into ocaml and was impressed by the type inference
system, proving that c++ templating is the wrong way, also the
pattern matching is a nice concept.
And concerning speed, ocamlc is unbeatable.

Just for fun I looked at the great language shootout page
and there is a nice score matrix.
I typed in for CPU 1, Memory 2 and Lines of Code 3 as factors and voila,
ocaml at the first two ranks and ruby at rank 5.

Finally it depends on matz’s language skills, impementing the
interpeter is hard enough and I think, a reasonable fast implementation
is possible in all of the common languages (non interpreted).

···

On Fri, 14 May 2004 08:23:51 +0900, Phil Tomson ptkwt@aracnet.com wrote:

I’ve been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit
easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C’s collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn’t be too hard
to build on existing code. Also, Objective C is supported by GCC.


Matthias Georgi
matti_g@gmx.de

Matz has also said that you shouldn’t write an OO language in an OO
language.

···

On Friday, 14 May 2004 at 8:23:51 +0900, Phil Tomson wrote:

In article 40A3E539.2010204@hypermetrics.com,

I’ve been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C’s collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn’t be too hard
to build on existing code. Also, Objective C is supported by GCC.


Jim Freeze
The man who follows the crowd will usually get no further than the
crowd. The man who walks alone is likely to find himself in places no
one has ever been.
– Alan Ashley-Pitt

I brought this up a long time ago, but I don’t know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Ideally, any extension written in ObjC would automatically be available in
Ruby.

Feasible? I have no idea, but if it is, it seems like you could get just about
all the features desired out of such a backend, since they’re already there in
the ObjC runtime.

Jim

···

On Fri, 14 May 2004 08:23:51 +0900 ptkwt@aracnet.com (Phil Tomson) wrote:

I’ve been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C’s collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn’t be too hard
to build on existing code. Also, Objective C is supported by GCC.

I’m trying to install Ruby’s readline module on OS X and am having the
following problem:

When I run:

ruby extconf.rb

I get:

checking for tgetnum() in -lncurses… yes
checking for readline/readline.h… yes
checking for readline/history.h… yes
checking for readline() in -lreadline… no

The question is, where are the paths that ‘have_library()’ is going to
search? It is finding the header files but can’t seem to find the
library (libreadline.a).

Thanks!

Steve

Why not cut out the middle man and write a gcc compiler for ruby? Just
to throw a crazy idea around.

J.
ps. like the sig.

···

On 14/05/2004, at 12:29 PM, Jim Freeze wrote:

On Friday, 14 May 2004 at 8:23:51 +0900, Phil Tomson wrote:

In article 40A3E539.2010204@hypermetrics.com,

I’ve been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit
easier
because Objective-C and Ruby have some things in common
philosophically.
Also you could take advantage of Obj-C’s collection classes where
needed.
Since Objective-C is just an add-on to C it probably wouldn’t be too
hard
to build on existing code. Also, Objective C is supported by GCC.

Matz has also said that you shouldn’t write an OO language in an OO
language.


Jim Freeze
The man who follows the crowd will usually get no further than the
crowd. The man who walks alone is likely to find himself in places no
one has ever been.
– Alan Ashley-Pitt

Jim Freeze wrote:

Matz has also said that you shouldn’t write an OO language in an OO
language.

Why not?

Wrote “James F. Hranicky” jfh@cise.ufl.edu, on Fri, May 14, 2004 at 07:44:04PM +0900:

···

On Fri, 14 May 2004 08:23:51 +0900 > ptkwt@aracnet.com (Phil Tomson) wrote:
I brought this up a long time ago, but I don’t know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Check out Ruby/cocoa, it sounds like what you want.

Sam


Sam Roberts sroberts@certicom.com

I brought this up a long time ago, but I don’t know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Ideally, any extension written in ObjC would automatically be available in
Ruby.

Have you tried RIGS or ruby-cocoa?

Ari

It looks like that it adds CONFIG[‘libdir’] to -L.

As a sidenote, perhaps it would be easier if you used a ports system to
compile your Unix stuff, like DawrinPorts. It saves me a good deal of
trouble.

···

On May 13, 2004, at 20:14, Stephen Steiner wrote:

The question is, where are the paths that ‘have_library()’ is going to
search? It is finding the header files but can’t seem to find the
library (libreadline.a).


Lo-lee-ta: the tip of the tongue taking a trip of three
steps down the palate to tap, at three, on the teeth.
Lo. Lee. Ta. GUO Shu-yu shu@rufuran.org

Have you installed a copy of readline on your system? There are two
possibilities here:

  1. make and install a readline library, or
  2. if you were lucky enough to have a copy installed with your
    developer tools, link it to your /usr/lib directory.

If a copy was installed, it should be under
“/System/Library/PrivateFrameworks/readline.framework/”; If it’s not
there, you’ll probably have to compile a copy.

Since it was installed on mine, I haven’t had to compile it. But I hear
that other people’s setups don’t have it, so I don’t know.

HTH,
–Mark

···

On May 13, 2004, at 5:14 PM, Stephen Steiner wrote:

I’m trying to install Ruby’s readline module on OS X and am having the
following problem:

When I run:

ruby extconf.rb

I get:

checking for tgetnum() in -lncurses… yes
checking for readline/readline.h… yes
checking for readline/history.h… yes
checking for readline() in -lreadline… no

The question is, where are the paths that ‘have_library()’ is going to
search? It is finding the header files but can’t seem to find the
library (libreadline.a).

Michael campbell wrote:

Jim Freeze wrote:

Matz has also said that you shouldn’t write an OO language in an OO
language.

Why not?

I think it had something to do with the mismatch between the languages.
Confusion between Ruby objects and C++ objects (which work differently)
and all that.

Easier to describe an OO language like Ruby procedurally. But IANYM.

Hal

No, but those don’t affect the way the backend runs, right? I’m thinking
that a pure ObjC backend would support native threads and be relatively fast,
things desired out of Rite.

I could be talking out of something other than my mouth, but I’d like to see
someone who knows what their talking about give an informed opinion :->

Jim

···

On Sat, 15 May 2004 00:27:40 +0900 Aredridel aredridel@nbtsc.org wrote:

I brought this up a long time ago, but I don’t know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Ideally, any extension written in ObjC would automatically be available in
Ruby.

Have you tried RIGS or ruby-cocoa?

In article 40A431B3.9060504@yahoo.com,

···

Michael campbell michael_s_campbell@yahoo.com wrote:

Jim Freeze wrote:

Matz has also said that you shouldn’t write an OO language in an OO
language.

Why not?

Maybe because the differences between the two object systems can get to be
confusing as you’re trying to implement a different object system on top
of another one. Maybe the implementation language’s object system would
have too much influence at a subconcious level.

I can kind of see his point.

Phil

I downloaded a precompiled bundle from a web site and dropped it into my
ruby lib according to instructions.

I downloaded it from the site mentioned here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/72433

I also tried building it according to a script in this email. The script
was pretty cool, but didn’t work for me, so I just downloaded the bundle
and followed the instructions. It’s worked great for me.

Nick

Stephen Steiner wrote:

···

I’m trying to install Ruby’s readline module on OS X and am having the
following problem:

When I run:

ruby extconf.rb

I get:

checking for tgetnum() in -lncurses… yes
checking for readline/readline.h… yes
checking for readline/history.h… yes
checking for readline() in -lreadline… no

The question is, where are the paths that ‘have_library()’ is going to
search? It is finding the header files but can’t seem to find the
library (libreadline.a).

Thanks!

Steve

Unfortunately, I often need the most recent builds of things and they
are not usually supported by the DarwinPorts as far as I can tell.

For example, I wanted to replace the Apple supplied Ruby with 1.8.1 but
I wanted the ‘stable-snapshot’ instead of the release version. As far
as I know, that would not be available using DarwinPorts.

Steve

···

On May 13, 2004, at 8:27 PM, Shu-yu Guo wrote:

On May 13, 2004, at 20:14, Stephen Steiner wrote:

The question is, where are the paths that ‘have_library()’ is going
to search? It is finding the header files but can’t seem to find the
library (libreadline.a).

It looks like that it adds CONFIG[‘libdir’] to -L.

As a sidenote, perhaps it would be easier if you used a ports system
to compile your Unix stuff, like DawrinPorts. It saves me a good deal
of trouble.

Lo-lee-ta: the tip of the tongue taking a trip of three
steps down the palate to tap, at three, on the teeth.
Lo. Lee. Ta. GUO Shu-yu shu@rufuran.org

‘IANYM’.gsub /.*/, ??

-a

···

On Fri, 14 May 2004, Hal Fulton wrote:

Michael campbell wrote:

Jim Freeze wrote:

Matz has also said that you shouldn’t write an OO language in an OO
language.

Why not?

I think it had something to do with the mismatch between the languages.
Confusion between Ruby objects and C++ objects (which work differently)
and all that.

Easier to describe an OO language like Ruby procedurally. But IANYM.

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================

Have you tried RIGS or ruby-cocoa?

No, but those don’t affect the way the backend runs, right? I’m thinking
that a pure ObjC backend would support native threads and be relatively fast,
things desired out of Rite.

Well, things written in ObjC appear as Ruby classes – it becomes a
second backend of sorts.

Ruby code is still run by the C interpeter, but it can call ObjC
classes.

I could be talking out of something other than my mouth, but I’d like to see
someone who knows what their talking about give an informed opinion :->

Rite or another implementation -could- be written in ObjC, and I’d love
to see it happen. Portability to Windows is an issue, but I’m content
there.

There are some things in Ruby that don’t map to ObjC, so a backend that
simply compiled Ruby to ObjC can’t happen: things like eval would have
to invoke the compiler, and Ruby allows a few things (like adding member
variables to classes at any time) that ObjC doesn’t.

Ari