CRuby (Was: R)

CRuby = subset of Ruby + typed methods + compiler to C

The main difference is the typing of functions and their
arguments. The generated source is intended to be linked with the Boehm GC.
By default methods return values of the same type as the receiver, but this
behaviour can be overridden with the -> operator.

The current “implementation” is definitely only a toy, but those interested
in the consept are welcome to the sources. I am going to mull over this for
a while further and either dump the sources on my homepage and leave it at
that – or register a Savannah project.

The next stage would be a proof-of-concept implementation that
automagically generates a ruby-api to the generated C-code.

Cheerio,

– Nikodemus

Example follows:

$ cat test.crb

def words -> String
"Hello World"
end

MAIN {
msg = words()
puts( msg )
}

$ ./cruby test.crb
$ cat test.c

#define _GNU_SOURCE

#include “test.h”

String *
Kernel_words ()
{
return “Hello World”;
}

void
crb_main ()
{
void * msg;
msg = Kernel_words ();
Kernel_puts (msg);
}

int
main ()
{
crb_init ();
crb_main ();
return 0;
}

Nikodemus Siivola wrote:

CRuby = subset of Ruby + typed methods + compiler to C

The name CRuby could be a little confusing. The Python people use
CPython to refer to the original Python interpreter, as opposed to the
Java implementation Jython (formerly JPython).
We have a Java implementation too, namely JRuby, but no widely accepted
name for the original Ruby interpreter.

/Anders

···


Anders Bengtsson ndrsbngtssn@yahoo.se


Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
Håll dig ajour med nyheter och resultat, med vinnare och förlorare…

I am probably a bit too late in that thread (have not read thread “R”),
but what kind of speed improvement are you hoping to achieve?

If speed is not the issue, what else is the motivation for
that substantial amount of work?

Thanks,
-A.

···

Armin Roehrl, http://www.approximity.com

I can’t understand why people are frightened of new ideas.
I’m frightened of the old ones.
– John Cage

Hello Nikodemus,

Thursday, October 03, 2002, 9:41:53 PM, you wrote:

CRuby = subset of Ruby + typed methods + compiler to C

The main difference is the typing of functions and their
arguments. The generated source is intended to be linked with the Boehm GC.
By default methods return values of the same type as the receiver, but this
behaviour can be overridden with the → operator.

The current “implementation” is definitely only a toy,

i don’t see “char*–>String*” converter, nor support for
variable-sized arguments list

but those interested
in the consept are welcome to the sources.

and i don’t see url :slight_smile:

···

String *
Kernel_words ()
{
return “Hello World”;
}

void
crb_main ()
{
void * msg;
msg = Kernel_words ();
Kernel_puts (msg);
}


Best regards,
Bulat mailto:bulatz@integ.ru

what about Objective C ??

s.

···

On Thu, 03 Oct 2002 17:42:49 GMT, Nikodemus Siivola tsiivola@cc.hut.fi wrote:

CRuby = subset of Ruby + typed methods + compiler to C

We have a Java implementation too, namely JRuby, but no widely
accepted
name for the original Ruby interpreter.

Maybe I’m being obtuse here, but I always considered the original
Ruby interpreter to be called “ruby”. I wasn’t aware there were
other names out there vying for contention.

···

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

Anders Bengtsson wrote:

Nikodemus Siivola wrote:

CRuby = subset of Ruby + typed methods + compiler to C

The name CRuby could be a little confusing. The Python people use
CPython to refer to the original Python interpreter, as opposed to the
Java implementation Jython (formerly JPython).
We have a Java implementation too, namely JRuby, but no widely accepted
name for the original Ruby interpreter.

What about RubyC (pronounced as Rubik)?

···


Giuseppe “Oblomov” Bilotta

“E la storia dell’umanità, babbo?”
“Ma niente: prima si fanno delle cazzate,
poi si studia che cazzate si sono fatte”
(Altan)
(“And what about the history of the human race, dad?”
“Oh, nothing special: first they make some foolish things,
then you study which foolish things have been made”)

My motivation is / was threefold:

  1. Curiosity: To see how it would be done.

  2. Study: A C-project I am working on has me more and more convinced that
    what I really want is a high-level C-generator. This was the first
    experiment.

  3. Speed: I have / had no concrete goals, and no benchmarks as of yet, but
    I would expect to land somewhere between Ruby and proper C.

– Nikodemus

···

On Fri, 4 Oct 2002, Armin Roehrl wrote:

but what kind of speed improvement are you hoping to achieve?
If speed is not the issue, what else is the motivation for

Hello Stefan,

Friday, October 04, 2002, 12:47:43 PM, you wrote:

CRuby = subset of Ruby + typed methods + compiler to C

what about Objective C ??

ruby has very good syntax and many perl-derived tricks

···


Best regards,
Bulat mailto:bulatz@integ.ru

Michael Campbell wrote:

Maybe I’m being obtuse here, but I always considered the original
Ruby interpreter to be called “ruby”. I wasn’t aware there were
other names out there vying for contention.

Michael,
I may be the obtuse one, since I had to look up the word “obtuse” in my
English-Swedish dictionary. :slight_smile:

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

/Anders

···


Anders Bengtsson ndrsbngtssn@yahoo.se


Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
Håll dig ajour med nyheter och resultat, med vinnare och förlorare…

  1. Curiosity: To see how it would be done.
    Curisoity is always a very good reason;
  2. Study: A C-project I am working on has me more and more convinced that
    what I really want is a high-level C-generator. This was the first
    experiment.
    I was once experimenting with mapping C-code to FPGAs, but
    6 years ago FPGA had a very limited number of gates (wire was the real
    problem). I got really frustated as my nice code didn’t fit at once as it
    was not always so easy to work out the exact size and wiring before, so
    I started writing a C-code generator to do a sort of binary-search of
    the largest-possible size. That was brute-force.

Whare are you working on.

  1. Speed: I have / had no concrete goals, and no benchmarks as of yet, but
    I would expect to land somewhere between Ruby and proper C.
    Makes sense and is a nice way of shipping Ruby applications.

Have fun,
-A.

Similar to perl and Perl cases?

···

On Fri, Oct 04, 2002 at 03:23:20AM +0900, Anders Bengtsson wrote:

Michael Campbell wrote:

Maybe I’m being obtuse here, but I always considered the original
Ruby interpreter to be called “ruby”. I wasn’t aware there were
other names out there vying for contention.

Michael,
I may be the obtuse one, since I had to look up the word “obtuse” in my
English-Swedish dictionary. :slight_smile:

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

/ Alexander Bokovoy


A mushroom cloud has no silver lining.

Whare are you working on.

http://www.nongnu.org/grt

Makes sense and is a nice way of shipping Ruby applications.

Yeah, but it does’t quite work out like that: a CRuby app is not a Ruby
app. :frowning:

– Nikodemus

···

On Fri, 4 Oct 2002, Armin Roehrl wrote:

Hello Anders,

Thursday, October 03, 2002, 10:23:20 PM, you wrote:

Michael Campbell wrote:

Maybe I’m being obtuse here, but I always considered the original
Ruby interpreter to be called “ruby”. I wasn’t aware there were
other names out there vying for contention.

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

in the ruby, “Ruby” and “ruby” is not the same things :)))

···


Best regards,
Bulat mailto:bulatz@integ.ru

Hi –

Michael Campbell wrote:

Maybe I’m being obtuse here, but I always considered the original
Ruby interpreter to be called “ruby”. I wasn’t aware there were
other names out there vying for contention.

Michael,
I may be the obtuse one, since I had to look up the word “obtuse” in my
English-Swedish dictionary. :slight_smile:

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

Since at the moment there’s no formal definition of Ruby abstracted
from the interpreter (ruby), I think having them share the name is the
clearest thing. It’s hard (for me) to know what it would mean, as of
now, to say, “I’m writing a program in Ruby,” except that the program
would run under ruby. (Not that that means it would not run under,
e.g., JRuby.)

David

···

On Fri, 4 Oct 2002, Anders Bengtsson wrote:


David Alan Black | Register for RubyConf 2002!
home: dblack@candle.superlink.net | November 1-3
work: blackdav@shu.edu | Seattle, WA, USA
Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com

Looks like you’re right :slight_smile:
It’s rather obvious about what (the interpreter or the language)
the given discussion is from a context of sentence. Isn’t it ?

···

On Fri, Oct 04, 2002 at 03:38:57AM +0900, Alexander Bokovoy wrote:

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?
Similar to perl and Perl cases?

[ Wojtek gminick Walczak ][ http://gminick.linuxsecurity.pl/ ]
[ gminick (at) hacker.pl ][ gminick (at) underground.org.pl/ ]

dblack@candle.superlink.net wrote:

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

Since at the moment there’s no formal definition of Ruby abstracted
from the interpreter (ruby), I think having them share the name is the
clearest thing. It’s hard (for me) to know what it would mean, as of
now, to say, “I’m writing a program in Ruby,” except that the program
would run under ruby. (Not that that means it would not run under,
e.g., JRuby.)

An interesting corner case is when you write a script in a language that
is clearly Ruby, but uses Java APIs not available in “ruby”.

But anyway, I think we can manage with “Ruby” for the language and
“ruby” for the original interpreter for most uses.

/Anders

···

A n d e r s B e n g t s s o n | ndrsbngtssn@yahoo.se
Stockholm, Sweden |


Gratis e-mail resten av livet på www.yahoo.se/mail
Busenkelt!

Since at the moment there’s no formal definition of Ruby abstracted
from the interpreter (ruby), I think having them share the name is the
clearest thing. It’s hard (for me) to know what it would mean, as of
now, to say, “I’m writing a program in Ruby,” except that the program
would run under ruby. (Not that that means it would not run under,
e.g., JRuby.)

It’s really simple: file names as in " require ‘graph’ " … a typically in
lowercase in Ruby, an so is the ruby interpreter.
Ruby as a concept is like a class of programs and is therefore named in
uppercase like “Graph.new”

Assuming JRuby covers the full Ruby language, both ruby and jruby would
interpret Ruby programs.

However, to paraphrase the introduction from “The Ruby Way”: mr. Fulton:
"When all nouns in german begin with uppercase, then why is “deutsch” in
lowercase - it’s the name of the language… The professor answered: “Don’t
fight it”. I liked that.
Except “deutsch” is an adjective different from the name of the german
language “Deutsch”. It’s an obvious mistake - germans don’t have exceptions
to rules :wink:

Mikkel

Hi –

Since at the moment there’s no formal definition of Ruby abstracted
from the interpreter (ruby), I think having them share the name is the
clearest thing. It’s hard (for me) to know what it would mean, as of
now, to say, “I’m writing a program in Ruby,” except that the program
would run under ruby. (Not that that means it would not run under,
e.g., JRuby.)

It’s really simple: file names as in " require ‘graph’ " … a typically in
lowercase in Ruby, an so is the ruby interpreter.

I figured it was because unix programs are usually lowercase.
Whatever :slight_smile:

Ruby as a concept is like a class of programs and is therefore named in
uppercase like “Graph.new”

Assuming JRuby covers the full Ruby language, both ruby and jruby would
interpret Ruby programs.

Yes – what I was getting at was the question of determining what
exactly “the full Ruby language” consists of :slight_smile: I think I’m in the
minority, in that I would actually advocate a formal definition.
Otherwise it’s hard, for me at least, to think of ruby as just one of
arbitrarily many ways to gain access to Ruby.

David

···

On Sat, 5 Oct 2002, MikkelFJ wrote:


David Alan Black | Register for RubyConf 2002!
home: dblack@candle.superlink.net | November 1-3
work: blackdav@shu.edu | Seattle, WA, USA
Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com

Hi –

Since the interpreter and the language share the same name, how do you
know if “ruby” refers to the interpreter or language?

Since at the moment there’s no formal definition of Ruby abstracted
from the interpreter (ruby), I think having them share the name is the
clearest thing. It’s hard (for me) to know what it would mean, as of
now, to say, “I’m writing a program in Ruby,” except that the program
would run under ruby. (Not that that means it would not run under,
e.g., JRuby.)

An interesting corner case is when you write a script in a language that
is clearly Ruby, but uses Java APIs not available in “ruby”.

That’s where I get caught in the philosophical question: without a
formal language definition, how can a program be said to be written in
Ruby, if it doesn’t run under ruby?

I don’t think this is likely to be a practical problem, since for any
given project (e.g., JRuby), things will be documented, and people
will know where they diverge, if at all. But it still stops me from
treating “Ruby” as an abstraction (yet).

David

···

On Sat, 5 Oct 2002, Anders Bengtsson wrote:

dblack@candle.superlink.net wrote:


David Alan Black | Register for RubyConf 2002!
home: dblack@candle.superlink.net | November 1-3
work: blackdav@shu.edu | Seattle, WA, USA
Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com