Which compiled language is closest to Ruby?

I am currently using C++ as my compiled language but fell in love with Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are object-oriented and have support for blocks/closures?

Thanks.

Gully Foyle wrote:

I am currently using C++ as my compiled language but fell in love with Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are object-oriented and have support for blocks/closures?

Well, there's Groovy. It depends on what you mean by "compiled". Groovy compiles to JVM bytecode, but perhaps you meant a language that compiles to your machine's bytecode?

···

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."

Hello Gully,

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

You can find this only in the area of functional languages. I don't
know any imperative compiled language that supports this feature.

···

--
Best regards, emailto: scholz at scriptolutions dot com
Lothar Scholz http://www.ruby-ide.com
CTO Scriptolutions Ruby, PHP, Python IDE 's

I've been looking at OCaml recently, and it seems like a pretty decent
compiled counterpart to Ruby. Just started learning it, so I can't
really tell you too much, but I know there are other OCaml fans in here.

martin

···

Gully Foyle <nospam@nospamnospamnospam.com> wrote:

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

Look for some kind of smalltalk. I think they're usually jitted like
Java, but there are some compilers (IIRC Smalltalk/X)

···

il Mon, 19 Jul 2004 04:17:17 GMT, Gully Foyle <nospam@nospamnospamnospam.com> ha scritto::

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

Gully Foyle wrote:

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

Apart from ML dialects such as SML or Ocaml, there are Lisp variants. These
are also closer to Ruby than ML in that they dynamically typed. Eg:
Common Lisp (supports closures and generic OO with CLOS, most
implementations compile to native code).
Some Schemes, such as Chicken or Bigloo. Both have object systems and
compile to C (and Java in Bigloo's case).
And a less well known Lisp, Dylan.

···

--
Grzegorz Chrupała | http://pithekos.net | grzegorzc@jabber.org
To describe religions as mind viruses is sometimes interpreted as
contemptuous or even hostile. It is both.
                           -- Richard Dawkins, A Devil's Chaplain

Gully Foyle wrote:

I am currently using C++ as my compiled language but fell in love with Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are object-oriented and have support for blocks/closures?

Thanks.

While technically interpreted from byte code C# in version 2.0 will have anonymous functions and yield syntax. I don't know if the anonymous functions are closures or not, but it will basically have blocks. You will not however be able to define them in similar syntax as ruby.

Charles Comstock

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 :slight_smile:

Which compiled language is the closest to ruby?

Isn't that obvious? C++, of course.

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. (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) Java, C#, etc., you
can write (and call) free functions, you can write generic code without casts,
you can write "functional" code, ... That's multi-paradigm programming.)

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.)

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.

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++.

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.

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.

For a fully object oriented compiled language you might want to take a
look at Eiffel.

Their is the original ISE Eiffel, which is free for non-commercial use:

There is also the open source SmartEiffel, which is just in the process
of release a new update.
http://smarteiffel.loria.fr

Hi,

Gully Foyle wrote:

I am currently using C++ as my compiled language but fell in love with Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are object-oriented and have support for blocks/closures?

Did you tried Sather?

Sather is a pure object-oriented language, and has Algol-like syntax, closures (but they are similar to method objects of Ruby), iterators
(but they are very different from iterators of Ruby), include (but it
doesn't force mixin).

I like Sather, but it is not so close to Ruby. Most different point is
that Sather is a strictly statically typed language.

The most serious problem is that there is no well maintained
implementation:(

Shugo

I haven't seen anyone mention it, but I believe Objective C has a similar
object model (everything derived from Object, methods not defined in the
current class get passed up to the parent, has exceptions, etc). Googling
for

  "Objective C" blocks

shows some proposals for adding blocks that may or may not have been accepted
into the language spec.

I've never actually programmed in it, so others may have better information.

Jim

···

On Mon, 19 Jul 2004 13:22:08 +0900 Gully Foyle <nospam@nospamnospamnospam.com> wrote:

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

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 :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

What do you really mean by "compiled"? Are you interested in
producing small, standalone executables? Or producing a library that
you can easily link to from C? Or is that you want to have more
static error checking (and if so, how much)? Or do you just mean
"fast"? (And in that case, fast for what? Fast as in integer and
floating point performance comparable to C, or fast as in 100x faster
than Ruby for method dispatch, or... ?)

The distinction between "compiled" and "interpreted" is a pretty
irrelevant one (and in fact these aren't mutually exclusive - a common
architecture for language platforms these days is to compile to
bytecode, which is then interpreted). If you want a sensible answer,
ask a more specific question.

Cheers,
Avi

D (http://www.digitalmars.com/d/\) is very similar to C++ and has
dynamic closures, garbage collector and some other features. It's not
close to Ruby but it's closer than C++.

Next thing I'd take into account is Jamis' suggestion Groovy
(http://groovy.codehaus.org/\). But this might be more interesting for
someone coming from Java.

As Gabriele already said: Smalltalk comes in many flavours. Smalltalk
MT (e. g. http://www.genify.com/whatisSTMT.htm\) creates small
executables on Win32.

Cheers
Sascha

···

Gully Foyle <nospam@nospamnospamnospam.com> wrote:

I am currently using C++ as my compiled language but fell in love with
Ruby recently :slight_smile:

Which compiled language is the closest to ruby? Are there any that are
object-oriented and have support for blocks/closures?

Lothar Scholz <mailinglists@scriptolutions.com> writes:

Hello Gully,

> I am currently using C++ as my compiled language but fell in love with
> Ruby recently :slight_smile:

> Which compiled language is the closest to ruby? Are there any that are
> object-oriented and have support for blocks/closures?

You can find this only in the area of functional languages. I don't
know any imperative compiled language that supports this feature.

Sather comes to my mind. It seems it is not longer supported but at
least one can download it from somewhere.

Regards
Friedrich

···

--
Please remove just-for-news- to reply via e-mail.

If you're considering Lisp, you might take a look at Goo -- it's an
OO, lexically-scoped Lisp dialect designed by Jonathan Bachrach, who
(IIRC) was one of the core implementers of the Apple Dylan compiler
and runtime. The compiler actually generates C code, which is compiled
and loaded at runtime by calling into libgcc to generate shared
objects from the generated sources and then dynamically loading the
.so.

Lennon

and the ICollection api seems quite similar to Enumerable in C# 2
(though I can't find the page where I first read it..)
Maybe Anders Hejlsberg is a reader of comp.lang.ruby :slight_smile:

···

il Mon, 19 Jul 2004 22:22:36 -0500, Charles Comstock <cc1@cec.wustl.edu> ha scritto::

While technically interpreted from byte code C# in version 2.0 will have
anonymous functions and yield syntax. I don't know if the anonymous
functions are closures or not, but it will basically have blocks. You
will not however be able to define them in similar syntax as ruby.

"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 :slight_smile:
>
> 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

Avi Bryant wrote:

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 :slight_smile:

Which compiled language is the closest to ruby? Are there any that are object-oriented and have support for blocks/closures?

What do you really mean by "compiled"? Are you interested in
producing small, standalone executables? Or producing a library that
you can easily link to from C? Or is that you want to have more
static error checking (and if so, how much)? Or do you just mean
"fast"? (And in that case, fast for what? Fast as in integer and
floating point performance comparable to C, or fast as in 100x faster
than Ruby for method dispatch, or... ?)

The distinction between "compiled" and "interpreted" is a pretty
irrelevant one (and in fact these aren't mutually exclusive - a common
architecture for language platforms these days is to compile to
bytecode, which is then interpreted). If you want a sensible answer,
ask a more specific question.

Cheers,
Avi

Great questions.

I'd like:

reasonably small standalone executables--doesn't have to be tiny like c programs. understandable to require a largish runtime as a shared library similar to gcj programs. must be impossible to automate creation of original source code from the executable.

ability to produce shared libraries in both Linux/*BSD and Windows (on Windows, I'd like to be able to use static libs I can use from Visual C++ 6 apps if possible in addition to dll)

speed? faster is nicer but it doesn't have to be a speed demon since I can use c/c++ to optimize where needed and its easy to call those from ruby. any improvement would be acceptable--even 1%.

You also might consider using Objective-C: easy to link into C
programs (since you can expose a standard C API, and call C libraries
natively), object model similar to Ruby (message-based method
invocations, runtime-extensible classes, etc.), and a complier that
works on Windows, Linux, OS X, and many other platforms.

Lennon

Hi All,

I got the following error trying to install FoxRuby via darwinports (via "sudo port install fxruby"), near the end of the install:

...
---> Installing fxscintilla
---> Fetching fxruby
---> Attempting to fetch FXRuby-1.0.27.tar.gz from http://us.dl.sourceforge.net/fxruby
---> Verifying checksum(s) for fxruby
---> Extracting fxruby
---> Applying patches to fxruby
---> Configuring fxruby
Error: Target com.apple.configure returned: configure failure: shell command "cd "/Users/nick/Projects/darwinports/dports/ruby/fxruby/work/FXRuby-1.0.27" && ruby -rvendor-specific install.rb config --prefix=/opt/local -- --with-fox-include=/opt/local/include/fox --with-fox-lib=/opt/local/lib --with-fxscintilla-include=/opt/local/include/fxscintilla --with-fxscintilla-lib=/opt/local/lib" returned error 127
Command output: sh: line 1: ruby: command not found

Any suggestions on what went wrong and if there is a manual step(s) I can or need to do to finish it off?

Thanks,
Nick