Ruby advantages over Perl

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

···


Marek Janukowicz

2 more…
-easy reading/writing
-iterators

Marek Janukowicz wrote:

···

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

Does anyone know where the Ruby mailing list is archived?
I once wrote an email that might be relevant to Marek here.

Regardless, I would also mention Ruby’s very clean C interface.

···

On Thu, Jun 12, 2003 at 08:16:51AM +0900, Marek Janukowicz wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

Marek Janukowicz


Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html

“Marek Janukowicz” childNOSPAM@t17.ds.pwr.wroc.pl wrote in message
news:slrnbefclg.6r9.childNOSPAM@child.t9.ds.pwr.wroc.pl

Could you give me some more clues (I am missing a lot for sure)?

Exception handling.

Sean O'Dell

I wouldn’t word it this way for a magazine, but, you don’t have to do that
god-awful blessing to create objects. Objects are first class citizens, not
a tacked on after thought.
The syntax and culture of Ruby encourage more readable and maintainable
code. Ie. less Snoopy swearing (@&$^^#@!).

Regards,
JJ

···

on 6/11/03 7:16 PM, Marek Janukowicz at childNOSPAM@t17.ds.pwr.wroc.pl wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

  • comp.lang.ruby

i think i’ve learned more about programming, especially object oriented
programming, on this list that from any other resource. in addition to that
it is easily the nicest list in town too. seriously, i have only been using
newsgroups for about 1 1/2 years, but i think it is a serious factor to
consider when chosing any open source software - oreily books can’t do it all.

-a

···

On Wed, 11 Jun 2003, Marek Janukowicz wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p(%.\x2d\x29…intern)’
====================================

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented

and OOP is easy to use - much more so than C++ and Java - certainly
more so than Perls afterthought OOP.

  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

C interfacing seems a lot more straightforward, too.

···


Rasputin :: Jack of All Trades - Master of Nuns

In article slrnbefclg.6r9.childNOSPAM@child.t9.ds.pwr.wroc.pl,

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

To the growing list I would add:

  1. Built-in types like Array seem to have more methods that work on them
    than Perl’s. ie. you can do this out of the box in Ruby, but I don’t
    think you can in Perl:

a = [‘a’,‘b’,‘c’,‘d’,‘e’]
b = a - [‘c’]
#b => [“a”, “b”, “d”, “e”]

  1. Ruby has a very nice case statement
  2. any type of object can be used as a key in a Ruby hash (Perl can only
    use strings as keys).
  3. Ruby has continuations
  4. yield and code blocks

Phil

···

Marek Janukowicz childNOSPAM@t17.ds.pwr.wroc.pl wrote:

If I were you, I would not stress individual advantages, because somebody will say “Language X can do this too!” Ruby is a great language because it’s easy to use. It’s easy to write clean OO. There’s a thousand little conveniences spread throughout the language. It doesn’t make you write stuff just so the compiler’s happy.

Jason Creighton

···

On 11 Jun 2003 23:08:02 GMT Marek Janukowicz childNOSPAM@t17.ds.pwr.wroc.pl wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

“Marek Janukowicz” childNOSPAM@t17.ds.pwr.wroc.pl

There are some obvious advantages of Ruby over Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

– Ruby has native (and hence very portable) and clean threading support.
– Ruby has blocks, continuations, closures and bindings.
– Ruby has open Class structre and highly extensible.

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:
the 1st thoughts that spring to my mind

pro:

  • Ruby code is easier to read. Readability facilitates communication.
    (more elegant)
  • friendly community; Perl has become too big.

contra:

  • RAA has a long way to go before it becomes CPAN
  • more people know Perl

links:

OO Programming is not the Panacee and I don’t like Ruby because my mind is
much less stimulated programming with it.
I mean if you have to “turn right and become red” then Ruby has already a
method doing that.
And you can use it like this : Object.turn_right_become_red
I prefer doing that by programming instead of writing something which
someone has already programmed for me. Because people saying that since they
program with Ruby they don’t want to program with another language are true
: they are not adapted anymore with popular but harder programming language.
I mean you have to train your brain and not to become lazy with it. That’s
why after programming a little bit with Ruby and with Perl I choose Perl.
Perl brings fun to programming also because you have to think. If "fun"
means to you playing video games instead of chess then Ruby is for you and
you will find a lot of obvious advantages of Ruby over Perl…

Anubis

“Marek Janukowicz” childNOSPAM@t17.ds.pwr.wroc.pl a écrit dans le message
news: slrnbefclg.6r9.childNOSPAM@child.t9.ds.pwr.wroc.pl

···

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

Marek Janukowicz

Daniel Carrera wrote:
Does anyone know where the Ruby mailing list is archived?
I once wrote an email that might be relevant to Marek here.

http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml

www.ruby-lang.com/en > left menu >Community>Mailing list

···

#---------------------------------------------------------------------------------#
etc…etc.etc…

You can read archived mails at the past mail archive site: ruby-talk
<<<HERE

etc…etc.
#---------------------------------------------------------------------------------#

-r.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Does anyone know where the Ruby mailing list is archived?
I once wrote an email that might be relevant to Marek here.

Regardless, I would also mention Ruby’s very clean C interface.

On Thu, Jun 12, 2003 at 08:16:51AM +0900, Marek Janukowicz wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA

Marek Janukowicz


Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE+57pWnxE8DWHf+OcRAt7/AJ9NZ9CgN6FTEGelSqJKrtgQ+b4GNwCfa6SP
/K2PURLLgPaK8DSLhZGu7RQ=
=9zkJ
-----END PGP SIGNATURE-----

Rodrigo Bermejo | rodrigo.bermejo@ps.ge.com
IT-Specialist | 8*879-0644

  1. any type of object can be used as a key in a Ruby hash (Perl can
    only use strings as keys).

I don’t think this is accurate. This works perfectly fine in perl:

$hash{1.0} = “foo”;
keys %hash # => “1” or 1, depending on context.

···

Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook™.
http://calendar.yahoo.com

[…]

  1. Built-in types like Array seem to have more methods that work on them
    than Perl’s. ie. you can do this out of the box in Ruby, but I don’t
    think you can in Perl:

a = [‘a’,‘b’,‘c’,‘d’,‘e’]
b = a - [‘c’]
#b => [“a”, “b”, “d”, “e”]

There’s no operator overloading of this sort, no. Of course,
this particular task could be viewed as a convenient façade
to the find and reject methods, which perl has as the grep
function.

@b = grep { $_ != 4 } @a;
b = a.reject { |e| e == 4 }

[…]

  1. any type of object can be used as a key in a Ruby hash (Perl can
    only use strings as keys).

Although it should be noted that references will be happily
stringified if used as keys and that there is a core module
Tie::RefHash that lets you use ‘real’ references as keys.

[…]

  1. yield and code blocks

These are trivial to implement, you just end up with a few
more keywords.

Basically, the main difference I usually see between Perl
and Ruby is that Ruby just gives you less ‘noise’. Take away
various characters from a Perl program and you approach the
Ruby one. Start restructuring your code to be more Rubyish,
you lose even more.

You can do anything in Perl that you can in Ruby, it’s just
that some things may require you to pull in a module or
write a few more characters.

cheers,

···


Iain.

Yes, I agree. I think it’s best to give some code examples. This is what
I’d suggest.

  • Present a simple problem.
  • Show a very natural and simple solution in Ruby.
  • Ask the reader, “how would you do this in Perl?”.

The issue is not that Perl “can’t do it”. Rather, it should be an example
where the Perl solution is either difficult, or not as clean as Ruby’s.

Here are two examples. The point of them is not that it’s hard to “do” in
Perl, but rather, that the Ruby solution has a very natural syntax.

Example 1:

···

On Thu, Jun 12, 2003 at 11:19:11AM +0900, Jason Creighton wrote:

If I were you, I would not stress individual advantages, because
somebody will say “Language X can do this too!” Ruby is a great language
because it’s easy to use. It’s easy to write clean OO. There’s a
thousand little conveniences spread throughout the language. It doesn’t
make you write stuff just so the compiler’s happy.

==========

Task: Compute factorials, combinations, permutations and binomial

  • ----- distributions.

Code:


Factorial.

class Fixnum
def !
self < 0 and raise "Factorial only defined for non-negative numbers"
self == 0 and return 1
self * (self - 1).
!
end
end

Permutations.

def P(n,x)
n.!/(n-x).!
end

Combinations.

def C(n,x)
n.!/( (n-x).! * x._! )
end

Binomail

def Binomial_P(n,p,x)
C(n,x) * px * (1-p)(n-x)
end

Note:


The last three functions are nearly identical to what you’d see
in the textbook. There is nearly zero mapping between math notation
and Ruby’s syntax. THAT is the power of Ruby’s OO. Ruby’s OO allow
me to make Ruby fit whatever my mental model is. Not the other way
around.

Example 2:

Task: Vector algebra in R^n (addition, subtraction, scalar

  • ----- multiplication).

Code:


class Array
def coerce(other)
return self, other
end
def (n)
n.kind_of?(Numeric) or raise "must multiply by a scalar"
self.map{|e| e
n}
end
def +(arr)
arr.class == Array or raise "must add/subtract vectors"
arr.length == self.length or raise "lengths don’t match"
sum = []
arr.length.times {|i| sum[i] = self[i] + arr[i]}
sum
end
def -(arr) self + (arr * (-1) ) end
end

Usage:


[1, 2, 3] + [2, 3, 4] #=> [3, 5, 7]
[1, 2, 3] * 2 #=> [2, 4, 6]
2 * [1, 2, 3] #=> [2, 4, 6]

Again, Ruby’s OO lets you adapt the language so you can write things
in correspondence to your mental model.

The Perl code would be something like:

&sum(@vector1, @vector2)
&prod(@vector, $scalar)

And the implementation itself would be more complicated.

I hope that some of this helps.


Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html

???
I guess you meant that Ruby has no native threads but rather green
threads, etc…

But I’m not sure this would be perceived as an advantage: some people
don’t care about threads working in DOS or portability.

···

On Thu, Jun 12, 2003 at 01:19:11PM +0900, Shashank Date wrote:

“Marek Janukowicz” childNOSPAM@t17.ds.pwr.wroc.pl

There are some obvious advantages of Ruby over Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

– Ruby has native (and hence very portable) and clean threading support.

_ _

__ __ | | ___ _ __ ___ __ _ _ __
’_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

what’s the difference between chattr and chmod?
SomeLamer: man chattr > 1; man chmod > 2; diff -u 1 2 | less
– Seen on #linux on irc

http://ruby-talk.org/

Regards,

Brian.

···

On Thu, Jun 12, 2003 at 08:25:55AM +0900, Daniel Carrera wrote:

Does anyone know where the Ruby mailing list is archived?

Does anyone know where the Ruby mailing list is archived?
I once wrote an email that might be relevant to Marek here.
try group-search on google
or directly here
http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml

good luck.
-A.

···

Regardless, I would also mention Ruby’s very clean C interface.

On Thu, Jun 12, 2003 at 08:16:51AM +0900, Marek Janukowicz wrote:

I am going to write an article to a software magazine titled “Ruby as an
alternative to Perl”. There are some obvious advantages of Ruby over
Perl:

  • Ruby is fully object oriented
  • blocks
  • introspection
  • very little difference between compile time and runtime

Could you give me some more clues (I am missing a lot for sure)?

TIA
– Marek Janukowicz

  • – Daniel Carrera | OpenPGP fingerprint:
    Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7
    7A88
    UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (SunOS)

iD8DBQE+57pWnxE8DWHf+OcRAt7/AJ9NZ9CgN6FTEGelSqJKrtgQ+b4GNwCfa6SP
/K2PURLLgPaK8DSLhZGu7RQ=
=9zkJ
-----END PGP SIGNATURE-----

    -A.

Armin Roehrl, http://www.approximity.com
We manage risk

I have to think enough as it is. I should use Perl to make my life
harder? Righty-ho. I get right on that.

···

At 21:21 12/06/2003 +0900, you wrote:

I mean you have to train your brain and not to become lazy with it. That’s
why after programming a little bit with Ruby and with Perl I choose Perl.
Perl brings fun to programming also because you have to think. If "fun"
means to you playing video games instead of chess then Ruby is for you and
you will find a lot of obvious advantages of Ruby over Perl…

Anubis