"Uwe Schnitker" <schnitkerAffenschaukel / sigma-c.com> schrieb im
Newsbeitrag news:30381f67.0407192151.25675ec2 / posting.google.com...
> Gully Foyle <nospam / nospamnospamnospam.com> wrote in message
news:<hXHKc.38807$eH1.18448437 / newssvr28.news.prodigy.com>...
> > I am currently using C++ as my compiled language but fell in love with
> > Ruby recently :)
> >
> > Which compiled language is the closest to ruby?
>
> Isn't that obvious?  C++, of course.

You are kidding, are you?

> > Are there any that are
> > object-oriented
>
> Both C++ and Ruby are multi-paradigm languages that support OO
programming,
> but don't try to enforce OO programming.

I don't subscribe to that.  Ruby is much more OO than C++.  C++ has POD's,
functions, static etc.  In Ruby, everything is an object and every method
has a receiver.

> (Unless, of course, you define OO
> to necessarily include dynamic typing. And please note that I also
understand
> that Ruby is implemented in an OO-centric way - "everything is an
object" -
> but my point is that, unlike with (earlier versions of)

I don't see the point in comparing current Ruby with old versions of Java
or whatsoever.

> Java, C#, etc., you
> can write (and call) free functions,

If you are referring to static methods, then that's not true for Ruby.
There is no such thing as a static method in Ruby.

> you can write generic code without casts,

You can write generic code, because Ruby is dynamically typed, but Ruby
does not support generic programming (like C++ with templates, Java
Generics and others do).  Although this may sound paradox, I'd say that a
static typed language is prerequisite for having generics.  And sice Ruby
is not static typed there's simply no need for generics.

> you can write "functional" code, ... That's multi-paradigm programming.)

I get the impression that you base your measure for closeness on this buzz
word.  Personally I don't think this is a good choice.  Of course, there's
always a perspective from which certain things look similar.  But the
question is how much information do you gain by stating "C++ and Ruby are
similar because they share some very abstract concepts".  That'll be true
for Ruby and other programming languages, too.

> > and have support for blocks/closures?
>
> OK, C++ doesn't support blocks/closures, but with templates and function
> objects etc. you can get fairly close. (Using libraries like function,
bind
> and lamda from boost it's even quite easy and straightforward to write.)

Blocks and closures are built into Ruby, while functors and such are an
add on of the std lib.  And they are not as convenient and easy to use as
Ruby blocks.  My 0.02EUR.

> Furthermore:
>
> The way STL algorithms work on iterators using function objects is -
from
> a somewhat high-level, design oriented perspective - very similar to the
> iterator stuff in Ruby.
>
> C++ has operator overloading similar to Ruby.

Although you have to admit that there are huge differences in how Ruby and
C++ treat operators and overloading.

> Policy-based design - often implemented using a combination of templates
> and inheritance - is something like module mixin in Ruby.
>
> The way blocks can be used in Ruby to encapsulate resource aquisition
and
> release, e.g. passing code to the open method of file, is similar, even
if
> somewhat turned inside-out, to using RAII in C++.

I regard this mechanism rather similar to Java's finally, because that's
what it is:

# allocate
begin
  # do stuff
ensure
  # deallocate
end

// allocate
try {
  // do stuff
}
finally {
  # deallocate
}

> Of course, Ruby is dynamically typed, dynamically evaluated and it's
type
> system can be manipulated directly at run-time. But these are issues
that
> are central to the compiled/interpreted distinction, unless you define
> compiled language in a very loose way.

True.

> When I first learned about Ruby, I instantly liked it, thinking:
> Hey, that's great, all the cool techniques I have been using in C++,
> especially when programming with STL and stuff (boost, Loki, whatever
....,
> and that I really like to use with C++, will be available in Ruby, too.

Ruby forces (or convinces) you much more to use these technics while C++
can be used in much more different ways and styles.  The fact, that you
can apply some of the technics Ruby uses in C or Assembler does not make
these languages similar to Ruby IMHO.

Regards

    robert