Oppure

Loading
07/07/09 16:49
evilmight
Postato originariamente da pierotofy:

Fonte: c2.com/cgi/…

- RubyLanguage is a pure ObjectOrientedProgrammingLanguage, Perl5 is less OO (but Perl 6 is coming with very good OO support).

- Perl has multiple variable types (scalar (a "single thing", capable of holding a string, a number, or a reference), array, hash). Ruby has one variable type: reference to object (the object can act like an array, hash, or whatever). Dereferencing references in Perl requires a specific syntax; in Ruby the dereferencing is automatic and transparent.

- Perl automatically converts strings to numbers and numbers to strings, depending on context. Perl can do this because it has different operators for numbers and strings; for example, "." for string concatenation and "+" for numeric addition. Ruby, on the other hand, doesn't auto-convert types, leaving it to the programmer to convert types explicitly (".to_i", ".to_f", and ".to_s";). This allows Ruby to overload operators cleanly; for example, using "+" for both string concatenation and numeric addition. Some methods also implicitly convert types (e.g., to_i, to_f, to_s as necessary).

* That's not necessarily a good thing. + is plus, and . is concat. 34 . 56 == 3456.
* Of course 34.to_i + 56.to_i == 3456 also, so this is merely a matter of coding style, not an advantage or a disadvantage.

- Perl5's syntax for defining objects is unnatural and difficult (to be kind about it). Ruby's syntax is natural and simple. Main reason for that is that Perl was originally not designed to be Object Oriented - OO was added on top of Perl4 - adding radically new concepts to a language is BAD!

- Among many differences are: a much better object system and much better functionals (being stuck with $_ is damned ugly IMO)...I write a lot of Perl code and practically think in it, but Ruby is still way easier for me to read. -- TheerasakPhotha



Particolarmente importante il fatto che Perl non è nato come linguaggio OOP ma è stato adattato successivamente... credo avresti dovuto approfondire Ruby un po' di più per poterlo apprezzare veramente. Comunque gusti son gusti :)

Mah dopo aver studiato semantica, variabili array ecc... di cui delle cose che ho letto me ne ricordo la metà, forse perchè non ero preso dal linguaggio altrimenti non mi capita di scordarmi molte cose...
Sicuramente è questione di gusti :)
aaa