Anything disappearing from Ruby for 2.0?

From: Chris Uppal [mailto:chris.uppal@metagnostic.REMOVE-THIS.org]
Subject: Re: anything disappearing from Ruby for 2.0?

Ferenc Engard wrote:

Candidates are:

  • Perl style variables

If you still intend to use ruby for one-liners, then they
should remain
IMHO. Anyway, they do not harm anybody. I vote to not removing them.

[I’m an outsider delurking on this newsgroup for the first time]

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.

yes, a lot of people say that this is a factor which causes them to avoid ruby and i understand that it could be a turn-off for someone being introduced to the language.
what i’d like to know chris is if you still feel that those perlisms are a turn-off for you.
i mean, i can understand that you would have been turned off initially, but do you still feel that they are a problem for you?
or did u mention that you were initially put off because it indicates that it would be a problem when ruby is advocated as an alternative to other languages.

-- chris

Gavri Savio Fernandez

···

What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. - Woody Allen

Gavri Savio Fernandez wrote:

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.

i mean, i can understand that you would have been turned off initially,
but do you still feel that they are a problem for you?
or did u mention that you were initially put off because it indicates
that it would be a problem when ruby is advocated as an alternative to
other languages.

Well, it’s difficult to tell whether I’d have changed my mind after a while,
but the Perlisms did put me off Ruby, which is why I never did start to use
it.

I’m still interested, though, so I lurk here occasionally, and watch
developments with hope.

-- chris

Gavri Savio Fernandez wrote:

yes, a lot of people say that this is a factor which causes them to avoid ruby and i understand that it could be a turn-off for someone being introduced to the language.
what i’d like to know chris is if you still feel that those perlisms are a turn-off for you.
i mean, i can understand that you would have been turned off initially, but do you still feel that they are a problem for you?
or did u mention that you were initially put off because it indicates that it would be a problem when ruby is advocated as an alternative to other languages.

Perhaps we can discuss what exactly are the Perlisms in Ruby that people
hate or see as a major turnoff.

···


dave

Gavri Savio Fernandez wrote:

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.

i mean, i can understand that you would have been turned off initially,
but do you still feel that they are a problem for you?
or did u mention that you were initially put off because it indicates
that it would be a problem when ruby is advocated as an alternative to
other languages.

Well, it’s difficult to tell whether I’d have changed my mind after a while,
but the Perlisms did put me off Ruby, which is why I never did start to use
it.

It’s a totally alien concept to me that the Perlisms should put
someone off Ruby. They may be ugly, but if everyone acknowledges
that, then isn’t that OK? Don’t get me wrong, I’ve seen some nasty
looking Ruby code in my time, but I’ve barely seen any code that uses
the Perlisms. They seem to exist in theory only (and in some
sysadmins’ tool chest, which noone should hold against them).

I’m still interested, though, so I lurk here occasionally, and watch
developments with hope.

-- chris

Gavin

···

On Monday, December 1, 2003, 3:22:10 AM, Chris wrote:

Chris Uppal wrote:

Gavri Savio Fernandez wrote:

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.

i mean, i can understand that you would have been turned off initially,
but do you still feel that they are a problem for you?
<…snip…>

Well, it’s difficult to tell whether I’d have changed my mind after a while,
but the Perlisms did put me off Ruby, which is why I never did start to use
it.

I’m still interested, though, so I lurk here occasionally, and watch
developments with hope.

– chris

Why have you not looked into perl? Or even ruby for that matter? I admit
when I first started working with ruby the $1, $2, $3 variables seemed a
bit strange, but after working with them I can certainly say it is a
feature that is both useful and understandable. Do you do much with
regular expressions? This is where the perl variables shine:

phone_number = “123-456-789”
if phone_number =~ /^(\d\d\d)-(\d\d\d)-(\d\d\d\d)$/
phone_number = “(” + $1 + “)” + " " + $2 + “-” + $3
end
puts phone_number #-> “(123) 456-7890”

These variables are very nice, however the variables that do tend to
obfuscate the language are the other $_, $, $… variables. It seems
like there should be better ways of finding out this kind of
information. Like a program object of some kind:

$program.pid #-> 123
$program.load_path #-> [/usr…]

···


John Long
http://wiseheartdesign.com

I wonder how hard it would be to make perlisms an addon?

require ‘perlisms’

It seems possible. And with the advent of method wrapping even more easily so.

-t0

I’m trying a very simple example of embedding Ruby in C and I can’t get it
to work, nor can i find any documentation on how to get it to work. Here’s
what I’ve got:

#include <ruby.h>

int main(int argc, char *argv[]) {
ruby_init();
rb_eval_string(“puts ‘hello world’”);
ruby_finalize();
return 0;
}

Here is what i get:

Compiling…
out.c
Linking…
out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string
Debug/out.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

out.exe - 4 error(s), 0 warning(s)

Any ideas? Thanks,

Zach

John W. Long wrote:

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.
[…]
Why have you not looked into perl? Or even ruby for that matter?

Um… Am I misunderstanding you ? I have looked at Ruby, I think that there
is much that is of value there, but there are some aspects I don’t like
(speaking here, again, as an outsider) and which put me off it.

I have also looked at Perl – about every two years since Perl 2 (or so), and
recoiled in baffled horror each time.

I admit
when I first started working with ruby the $1, $2, $3 variables seemed a
bit strange, but after working with them I can certainly say it is a
feature that is both useful and understandable.

I’m a long time UNIX programmer, so the ‘$’ variables, don’t seem specially
strange, I just don’t think they have any place in a language that I want
to use for my purposes. I’m very familar with shell programming, so I speak
{k,ba,}sh + awk + happily, and feel no need for a scripting language
to replace that combo; what I would like to find is a flexible, properly
dynamic, totally OO, reasonably scaleable, language for use in contexts where
I’m not being obliged to use C++ or Java, and where I’m not able to use my
preferred Smalltalk. Ruby so nearly fits the bill – kinda fustrating :wink:

Do you do much with
regular expressions? This is where the perl variables shine:

To be honest, I see very little value in regexps as a syntactic language
feature (as opposed to being in a standard library). I don’t object to it,
but it doesn’t seem to buy much in return for the extra complexity. (And, too,
if the regexps are given their own syntax, then there’s a tempation to try to
make all features of regexps available as syntax, rather than just the subset
that is easy to read). Of course, that is partly a reflection of my own
programming (outside a scripting context) where I’ve tended to find that using
regexps is a short-cut that I eventually regret.

-- chris

Here is what i get:

Compiling…
out.c
Linking…
out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string
Debug/out.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

out.exe - 4 error(s), 0 warning(s)

Any ideas? Thanks,

Isn’t this just a C linker error? I’ve never embedded ruby myself, but
it seems there’s a missing lib file containing the object code for
functions ruby_init, ruby_finalize and rb_eval_string.

Ron

Assuming that you are correctly linking against the ruby library, you also
need to ensure that the RUBY_EXTERN macro (1.8.x) is defined properly (or the
EXTERN macro for ruby 1.6.x). Look inside Ruby’s define.h file to see if
this macro is being defined properly for your situation. If it is not, then
you may have to ensure manually that it is defined in an appropriate manner.
For instance, you are using Windows, so:

#define RUBY_EXTERN extern __declspec(dllimport)
#include <ruby.h>

– ES

···

On Tue, 2 Dec 2003 13:15:23 +0900, Zach Dennis wrote:

out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string

I really don’t understand this. You won’t use Ruby b/c it has some EXTRA
Perl-like features? D.N.C. Just don’t use them.

-t0

···

On Tuesday 02 December 2003 01:47 pm, Chris Uppal wrote:

John W. Long wrote:

I want to add the observation that the Perlisms in Ruby were
a major (perhaps
the major) factor that put me off the language when I
looked at it a year or
so ago.

[…]
Why have you not looked into perl? Or even ruby for that matter?

Um… Am I misunderstanding you ? I have looked at Ruby, I think that
there is much that is of value there, but there are some aspects I don’t
like (speaking here, again, as an outsider) and which put me off it.

I have also looked at Perl – about every two years since Perl 2 (or so),
and recoiled in baffled horror each time.

I admit
when I first started working with ruby the $1, $2, $3 variables seemed a
bit strange, but after working with them I can certainly say it is a
feature that is both useful and understandable.

I’m a long time UNIX programmer, so the ‘$’ variables, don’t seem specially
strange, I just don’t think they have any place in a language that I
want to use for my purposes. I’m very familar with shell programming, so
I speak {k,ba,}sh + awk + happily, and feel no need for a
scripting language to replace that combo; what I would like to find is a
flexible, properly dynamic, totally OO, reasonably scaleable, language for
use in contexts where I’m not being obliged to use C++ or Java, and where
I’m not able to use my preferred Smalltalk. Ruby so nearly fits the bill
– kinda fustrating :wink:

Thanks for replying Ron. I have recently made the move from scripting
languages to real languages and I’m quite new to compiling.

Zach

···

-----Original Message-----
From: Ron Coutts [mailto:rcoutts@envistatech.com]
Sent: Monday, December 01, 2003 11:23 PM
To: ruby-talk ML
Subject: Re: Embedding Ruby in C

Here is what i get:

Compiling…
out.c
Linking…
out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string
Debug/out.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

out.exe - 4 error(s), 0 warning(s)

Any ideas? Thanks,

Isn’t this just a C linker error? I’ve never embedded ruby myself, but
it seems there’s a missing lib file containing the object code for
functions ruby_init, ruby_finalize and rb_eval_string.

Ron

Thanks for the reply Eric. I checked the defines.h file and it has the line
in it that you suggested. I tried to manually add them to my .c file, but
still no go. Anymore ideas? Here is what I have tried from the command line:

cl out.c
cl out.c -IC:\source\ruby-1.8.1
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\bin
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\lib
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\source\ruby-1.8.1

Each one of the above is giving me the exact same error as before. I’ve
tried on Windows 2000 and WinXP.

Zach

···

-----Original Message-----
From: Eric Sunshine [mailto:sunshine@sunshineco.com]
Sent: Tuesday, December 02, 2003 12:10 AM
To: ruby-talk ML
Subject: Re: Embedding Ruby in C

On Tue, 2 Dec 2003 13:15:23 +0900, Zach Dennis wrote:

out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string

Assuming that you are correctly linking against the ruby library, you also
need to ensure that the RUBY_EXTERN macro (1.8.x) is defined properly (or
the
EXTERN macro for ruby 1.6.x). Look inside Ruby’s define.h file to see if
this macro is being defined properly for your situation. If it is not, then
you may have to ensure manually that it is defined in an appropriate manner.
For instance, you are using Windows, so:

#define RUBY_EXTERN extern __declspec(dllimport)
#include <ruby.h>

– ES

T. Onoma wrote:

[…] Ruby so nearly fits the bill – kinda fustrating :wink:

I really don’t understand this. You won’t use Ruby b/c it has some EXTRA
Perl-like features?

Yes, that’s right.

Elegance, simplicity, clarity – the things that (IMO) are necessary for a
language to have that “effortless” feeling – are dependent (among other
things) on a reasonably complete absence of clutter and other warts.

For me the stuff starting on p216 of the pickaxe is a long list of warts. (I
emphasise that I’m not knocking Ruby; it’s just that its current form is
optimised for use in a certain way – shortish scripts – that I’m not
interested in, and so those features of the language add clutter without
providing compensating value.)

Just don’t use them.

That’s sort of like saying “if you don’t like foul language then don’t swear”
:wink:

-- chris

What’s the compile command line look like? Seems to me that you’re
trying to link without telling the compiler where the implementation of
ruby_init(), etc. are located.

You need to find out what the name of the shared library (or static
library, which ever you prefer) for your operating system (For example,
on a Linux system the library might be ruby.so or ruby.lib, I don’t know
what it’s actually called :slight_smile: ) and link that file to your program.

e.g.
Suppose the library is actually ruby.so
Suppose you’re using cc for c compiles

cc out.c -lruby.so

Hope this helps! Sorry I couldn’t be more accurate.

Regards,
Brad

Ron Coutts wrote:

···

Here is what i get:

Compiling…
out.c
Linking…
out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string
Debug/out.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

out.exe - 4 error(s), 0 warning(s)

Any ideas? Thanks,

Isn’t this just a C linker error? I’ve never embedded ruby myself, but
it seems there’s a missing lib file containing the object code for
functions ruby_init, ruby_finalize and rb_eval_string.

Ron

It does not appear that you are linking with the Ruby library. You need to
link against the library in order for those symbols to be resolved. You
should read the Microsoft documentation to find out how to specify the
library on the command-line. (Based upon my reading, I got the impression
that you can simply specify the library at the end of the command-line after
the other options following /link. You may also need to specify /libpath in
order to let the linker know where the library is.)

Depending upon which version and which binary distribution of Ruby you are
using, the library might be named something like mswin32-ruby18.lib. If you
are using the source code distribution of Ruby then make sure that you have
actually built the project so that the .lib file exists.

At run-time, you may also need to place the Ruby .dll in the same directory
as your .exe file, or make sure that your PATH environment variable mentions
the directory containing the Ruby .dll.

– ES

···

On Tue, 2 Dec 2003 14:42:26 +0900, Zach Dennis wrote:

Thanks for the reply Eric. I checked the defines.h file and it has the line
in it that you suggested. I tried to manually add them to my .c file, but
still no go. Here is what I have tried from the command line:
cl out.c
cl out.c -IC:\source\ruby-1.8.1
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\bin
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\ruby\lib
cl out.c -IC:\source\ruby-1.8.1 /link /INCLUDE:C:\source\ruby-1.8.1
Each one of the above is giving me the exact same error as before. I’ve
tried on Windows 2000 and WinXP.

Hi –

T. Onoma wrote:

[…] Ruby so nearly fits the bill – kinda fustrating :wink:

I really don’t understand this. You won’t use Ruby b/c it has some EXTRA
Perl-like features?

Yes, that’s right.

Elegance, simplicity, clarity – the things that (IMO) are necessary for a
language to have that “effortless” feeling – are dependent (among other
things) on a reasonably complete absence of clutter and other warts.

For me the stuff starting on p216 of the pickaxe is a long list of warts. (I
emphasise that I’m not knocking Ruby; it’s just that its current form is
optimised for use in a certain way – shortish scripts – that I’m not
interested in, and so those features of the language add clutter without
providing compensating value.)

You can write short programs in Ruby, but it’s not optimized one way
or the other in that regard. Speed can be an issue, but there’s
nothing whatsoever in Ruby’s syntax or design to stop one from writing
longer programs. (Rich Kilmer and Dave Thomas among others can bear
witness to this :slight_smile: In sum, Ruby is a nice general-purpose programming
language; it’s not an admin-script niche tool.

David

···

On Wed, 3 Dec 2003, Chris Uppal wrote:


David A. Black
dblack@wobblini.net

Actually that’s exactly right.

You may not like foul language, but there’s little you can do about other
people’s use of it --short of depriving yourself of the the rest of the
wonderful world, living in a box and never coming out.

And so it is with Ruby. I can write obfuscated code with or without perlisms,
and there’s nothing you can do about it. But you deprive yourself from all of
Ruby’s bebefits, simply because you won’t manage with a few distates.

In other words, I think your hurting no one but yourself.

Sincerely,

T.

···

On Tuesday 02 December 2003 04:42 pm, Chris Uppal wrote:

Just don’t use them.

That’s sort of like saying “if you don’t like foul language then don’t
swear” :wink:

I got it! Brad you are an inspiration!!! Here’s the cl line I got to work:

cl test.c /link /LIBPATH:c:\source\ruby-1.8.1 msvcrt-ruby18.lib

At first I tried giving an absolute path to the file(
“c:\source\ruby-1.8.1\msvcrt-ruby18.lib” ) but later saw an example on the
python newsgroup showing the( “c:\source\ruby-1.8.1 msvcrt-ruby18.lib” ).

I first tried to link against the msvcrt-ruby18-static.lib because it is
almost 3.5mb, but it didn’t work. It gave me a bunch more unresolved
external symbol errors. The msvcrt-ruby18.lib seemed to do the job and when
i was done, i ran it. It worked great!! It was just a simple hello world
app.

Thanks alot to Brad and Ron for posting their responses.

-Zach

For any search engines scanning this page: msvc microsoft visual c++
embedding ruby into C program

···

-----Original Message-----
From: Brad [mailto:coish@hfx.eastlink.ca]
Sent: Tuesday, December 02, 2003 7:07 PM
To: ruby-talk ML
Subject: Re: Embedding Ruby in C

What’s the compile command line look like? Seems to me that you’re
trying to link without telling the compiler where the implementation of
ruby_init(), etc. are located.

You need to find out what the name of the shared library (or static
library, which ever you prefer) for your operating system (For example,
on a Linux system the library might be ruby.so or ruby.lib, I don’t know
what it’s actually called :slight_smile: ) and link that file to your program.

e.g.
Suppose the library is actually ruby.so
Suppose you’re using cc for c compiles

cc out.c -lruby.so

Hope this helps! Sorry I couldn’t be more accurate.

Regards,
Brad

Ron Coutts wrote:

Here is what i get:

Compiling…
out.c
Linking…
out.obj : error LNK2001: unresolved external symbol _ruby_init
out.obj : error LNK2001: unresolved external symbol _ruby_finalize
out.obj : error LNK2001: unresolved external symbol _rb_eval_string
Debug/out.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

out.exe - 4 error(s), 0 warning(s)

Any ideas? Thanks,

Isn’t this just a C linker error? I’ve never embedded ruby myself, but
it seems there’s a missing lib file containing the object code for
functions ruby_init, ruby_finalize and rb_eval_string.

Ron

David A. Black wrote:

I really don’t understand this. You won’t use Ruby b/c it has some EXTRA
Perl-like features?

Yes, that’s right.

Elegance, simplicity, clarity – the things that (IMO) are necessary for a
language to have that “effortless” feeling – are dependent (among other
things) on a reasonably complete absence of clutter and other warts.

For me the stuff starting on p216 of the pickaxe is a long list of warts. (I
emphasise that I’m not knocking Ruby; it’s just that its current form is
optimised for use in a certain way – shortish scripts – that I’m not
interested in, and so those features of the language add clutter without
providing compensating value.)

You can write short programs in Ruby, but it’s not optimized one way
or the other in that regard. Speed can be an issue, but there’s
nothing whatsoever in Ruby’s syntax or design to stop one from writing
longer programs. (Rich Kilmer and Dave Thomas among others can bear
witness to this :slight_smile: In sum, Ruby is a nice general-purpose programming
language; it’s not an admin-script niche tool.

My only comment in favor of what the OP says is this.

When I say “Perlisms” I’m chiefly talking about the
ugly variables such as $/ and $whatever (and the
special behaviors associated with them).

I don’t like the Perlisms and I don’t use them. (Note
how rarely they appear in The Ruby Way.) So far, so
good.

But what if I have to read the code of someone else who
uses them? For me, that’s a negative.

Another more subtle negative is: The presence of the
support for the Perlisms increases the complexity of
the interpreter, possibly making it slower or less
maintainable.

As always, Matz is boss. Whatever he puts in or leaves
out, I will get used to it and probably even like it.

Hal