lowering ruby's reach

J

jm

Being intentionally vague here so as not to ask a leading question. Has
anyone given any thought to what ruby needs to make it reach lower into
areas where even now C/C++ and assembler are used? Apart from native
compilation and byte code to add speed to the language. What would be
useful language features to add to allow ruby to be more suited to
things such as direct use with hardware and embedded application? Would
it be possible to make it suitable for OS and (hard) real-time
programming without losing the things that make ruby great at the
moment?

Jeff.
 
C

Caleb Clausen

Has anyone given any thought to what ruby needs to make it reach lower in=
to
areas where even now C/C++ and assembler are used?

You look at zenspider's stuff yet?

The short answer: you need ways to constrain the dynamism of the
language so the program is more predictable. Constraining the types of
various expressions is probably the most straight-forward way to
start.
Would it be possible to make it suitable for OS and (hard) real-time
programming without losing the things that make ruby great at the moment?

Garbage collection is the big barrier for real time stuff. Handling
more dynamic stuff like method_missing and const_missing would be next
hardest. There's a whole pile of challenges, actually.

Some will claim that all the extra nailing down and such of datatypes
that's done in static languages to make them faster makes programming
less fun.... I don't mind some of that personally, but it sure is nice
not to have to declare everything.
 
J

jm

You look at zenspider's stuff yet?

I've been watching this and yarv with interest. I've tried yarv, but
not zenspider's stuff as I've been waiting for a stable release and
possible a how-to or walk through. Yet, this is just bolting C closer
to ruby. It's like inline assembler. Don't get me wrong it should make
it a lot easier to write extensions for ruby - especially those that
are merely for speed gains.
The short answer: you need ways to constrain the dynamism of the
language so the program is more predictable. Constraining the types of
various expressions is probably the most straight-forward way to
start.

This was what I was thinking, but raising static typing here may get
you shouted at as a heretic. I missed the garbage collector, but now
that you mention is it's obvious. And, didn't realise that
missing_method and alike would case a problem.

What I was think of was the introduction of language profiles which
would trigger certain language features. I wouldn't what to lose ruby's
dynamic behavior which allows me to sketch out programs fast, but I
would like to restrict it when it comes to producing production code or
libraries for general consumption. Further from what little I've read
it seems to be easier to produce jit and native compilers for
statically typed languages and it's easier to make them faster (a
counter example here may be python's psyco engine). This would look
like the following,

# normal ruby code
a=5
puts a
a="hello world"
puts a

while with static typing,

language_profile static_types
a=5
puts a
a="hello world"
puts a

would refuse to run complaining about "hello world" not being an int.

language_profile static_types,declarations
a=5
puts a

would complain about variable a not being declared and would need to be
change to include a forward declaration,

language_profile static_types,declarations
Int a=5
puts 5

which would work, note that a is declared a Class Int. the
language_profile would be declared at a file level. These are trivial
examples and there may be a better way to do this. If there is don't be
shy (not that anyone on this list would be), but before you say it I
use unit testing extensively.

In short, what I'm trying to think of language features that would,

1) widen ruby's usefulness
2) make it easier for the writers of language tools to implement
3) make it easy for the users of ruby to take advantage of.
4) increase the acceptance of ruby (eg, by squashing concerns about
robustness and speed).
5) maintain backward compatibility.
6) keep ruby fun

With regard to point 6, I've already mentioned that one of the reasons
I like ruby is that it's easy to sketch out programs before you have
everything mapped out. This make it a good prototyping language as well
as a good language for web and sysadmin work. This is a lot harder, at
least for me, in C/C++.

Jeff.
 
J

jm

Can't remember if I've seen this before or not. A couple of comments,
done quickly while doing other things,

* Don't get me started on templates. That's what's causing me headaches
at the moment. I'm trying to re-write something I originally had in
ruby into C++.

* The strong/weak static/dynamic manifest/implicit argument seems to
take diametrically opposing points of view. Is it possible that there's
a third side to this argument?

* I like the point made in the article that algorithmic correctness is
not guaranteed by typing (weak or strong).

* For some reason I keep typing string when I mean strong. :^).

* I suppose what I was thinking with the language_profile email was
signaling to interpreter/compiler what optimisations and checks it
can/should run at a particular level in the code rather than or
necessarily on the entire body of code.

good quote from article, Guido van Rossum says,

You can also easily write a small piece of code in Python and see
that it works. You can
do very fine-grained unit testing. Bottom-up program development
works really well. You
can easily start with only a vague idea of what you want, start to
implement it, and see
how well it works so far. You can then change many things around. If
you have a strongly
typed language, changing things around becomes much more painful.

this equally applies to ruby.

I'll have to read to comments/article more fully sometime.

Jeff.
 
I

Isaac Gouy

jm wrote:
-snip-
* The strong/weak static/dynamic manifest/implicit argument seems to
take diametrically opposing points of view. Is it possible that there's
a third side to this argument?

Several third sides:
- strong/weak are just emotionally loaded stand-ins for good/bad (in
contrast to the technical term 'type safe')
- static/dynamic isn't a nice dichotomy ('static' languages may also do
dynamic type checks)
- manifest/latent explicit/implicit, skilled users of type inferenced
languages often explicitly declare types ('typeful' programmers think
in terms of types and like to see type info).

* I like the point made in the article that algorithmic correctness is
not guaranteed by typing (weak or strong).

Death and Taxes are guaranteed, everything else...

* For some reason I keep typing string when I mean strong. :^).

* I suppose what I was thinking with the language_profile email was
signaling to interpreter/compiler what optimisations and checks it
can/should run at a particular level in the code rather than or
necessarily on the entire body of code.

good quote from article, Guido van Rossum says,

You can also easily write a small piece of code in Python and see
that it works. You can
do very fine-grained unit testing. Bottom-up program development
works really well. You
can easily start with only a vague idea of what you want, start to
implement it, and see
how well it works so far. You can then change many things around. If
you have a strongly
typed language, changing things around becomes much more painful.

this equally applies to ruby.

No doubt Haskell programmers would say it's easy to do bottom-up
program development, and changing things around in their strong typed
language is easy.
 
D

Dave Burt

jm said:
I've been watching this and yarv with interest. I've tried yarv, but not
zenspider's stuff as I've been waiting for a stable release and possible a
how-to or walk through. Yet, this is just bolting C closer to ruby. It's
like inline assembler. Don't get me wrong it should make it a lot easier
to write extensions for ruby - especially those that are merely for speed
gains.

That doesn't sound like Ruby2C. From http://rubyforge.org/projects/ruby2c/ -

ruby2c is a subset of the metaruby project, which aims at rewriting ruby's
internals in ruby. ruby2c is the translation module and can automatically
translate a method into equivalent C code for a subset of ruby. Very BETA,
but making rapid progress.

I think it is kind of what you're looking for.

Cheers,
Dave
 
J

jm

That doesn't sound like Ruby2C. From
http://rubyforge.org/projects/ruby2c/ -


whoops, got a little confused there. I was actually thinking of the
inline stuff. However, you note that in
http://www.zenspider.com/~ryand/Ruby2C.pdf

in slide 10 they state "Needs to be rewritten in the ruby2c subset"
when referring to the ruby Interpreter and other parts in the following
slides if it was to use ruby2c. Note also that in slide 25 the types
are inferred to be of type int. What happens if you change a variables
type? Does it silently turn off conversion, refuse to convert, produce
two versions of the code or something else entirely? What I was think
with the language_profile statement is that you can indicate to the
compiler/interpreter what is the expected behavior so that if you code
with one set of assumptions in mind the compiler won't switch to
another. Equally you can tell it's alright to assume somethings because
your aware of those assumptions and have taken factors into
consideration. Further, it should warn you if you ask it to about
certain things which in other situations would be quite normal.

This approach would be advantageous compared to command line switches
because of the level of granularity it gives you. It would allow you to
set this on differing scopes with in the same program. Allowing the
programmer greater control and letting the compiler match the
programmers understanding and requirements better.

After think about my original post a bit more there's a few things that
could be done better. For example, forward declarations example is no
good as it's too simple and it could be done in way the is more
compatible with the standard ruby interpreter. The trouble is that this
is a blurry subject at best. And, my understanding of it is limited
which is why I'm asking questions and thinking aloud.

Jeff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top