Ruby advantages over Perl 
Author Message
 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



Mon, 28 Nov 2005 07:08:02 GMT  
 Ruby advantages over Perl

Quote:

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

Exception handling.

    Sean O'Dell



Mon, 28 Nov 2005 07:21:08 GMT  
 Ruby advantages over Perl

2 more..
-easy reading/writing
-iterators

Quote:

>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



Mon, 28 Nov 2005 07:22:36 GMT  
 Ruby advantages over Perl
-----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.

Quote:

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



Mon, 28 Nov 2005 07:25:55 GMT  
 Ruby advantages over Perl
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.

Quote:
>-----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.


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

--
-------------------------------------------------

IT-Specialist         | 8*879-0644            
-------------------------------------------------


Mon, 28 Nov 2005 07:36:09 GMT  
 Ruby advantages over Perl


Quote:

> 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

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

Regards,
  JJ



Mon, 28 Nov 2005 07:56:08 GMT  
 Ruby advantages over Perl

Quote:

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

- 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
--
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328

  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | ~ > ruby -e 'p(%.\x2d\x29..intern)'
  ====================================



Mon, 28 Nov 2005 08:10:50 GMT  
 Ruby advantages over Perl

Quote:

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

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



Mon, 28 Nov 2005 08:56:22 GMT  
 Ruby advantages over Perl


Quote:

>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"]

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

Phil



Mon, 28 Nov 2005 09:26:28 GMT  
 Ruby advantages over Perl

Quote:
> 3) 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(TM).
http://calendar.yahoo.com



Mon, 28 Nov 2005 10:06:55 GMT  
 Ruby advantages over Perl
On 11 Jun 2003 23:08:02 GMT

Quote:

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

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



Mon, 28 Nov 2005 10:07:20 GMT  
 Ruby advantages over Perl

[...]

Quote:
> 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 = a.reject { |e| e == 4 }

[...]

Quote:
> 3) 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.

[...]

Quote:
> 5) 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.



Mon, 28 Nov 2005 10:23:43 GMT  
 Ruby advantages over Perl
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quote:

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

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

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) * p**x * (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:
- ------

Quote:
>> [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:



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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQE+5/M/nxE8DWHf+OcRAsLyAJ9BnT0VwDx1/EQIgx41w12oi3dT4gCfXYvA
M8acDWe+YKAlFs1llqAgf8M=
=bwB/
-----END PGP SIGNATURE-----



Mon, 28 Nov 2005 11:28:06 GMT  
 Ruby advantages over Perl


Quote:
>  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.


Mon, 28 Nov 2005 12:10:41 GMT  
 Ruby advantages over Perl


Quote:

>[...]
>> 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 = a.reject { |e| e == 4 }

I didn't mean to imply it was impossible in Perl, but it's much easier and
more convenient in Ruby.

Quote:

>[...]
>> 3) 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.

>[...]

Fair enough.

Quote:
>> 5) yield and code blocks

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

I'm a bit skeptical that it would be trivial to implement yield in Perl.
...not saying it would be impossible to implement, but I'm thinking it
wouldn't be trivial.

Quote:

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

True.  Languages influence how we think about problems, and while you can
program in a Perlish way in Ruby (a lot of us started out that way ;-)
it's probably more difficult (or it doesn't occur to the Perl programmer)
to program in a Rubyish way in Perl.

Phil



Mon, 28 Nov 2005 13:02:59 GMT  
 
 [ 85 post ]  Go to page: [1] [2] [3] [4] [5] [6]

 Relevant Pages 

1. My Perl to Ruby Story (was: perl and rub y)

2. Perl => Ruby

3. Perl and Ruby: an Irony

4. Ruby<->Perl and syck-0.25 problem

5. Perl \G in Ruby regex?

6. The Year In Scripting Languages Lua/Perl/Python/Ruby/Tcl 2002

7. Ruby in The Perl Journal

8. Ruby in The Perl Review

9. Perl interpreter for Ruby?

10. Two Perl -> Ruby Questions

11. perl with HTML::Mason or Ruby with Eruby ??

12. Ruby equivalent to perl's...

 

 
Powered by phpBB® Forum Software