First off, the facts: '''Similarity''' * ScriptingLanguage * Ruby syntax is largely inspired by Perl's. * Supports GarbageCollection -- the current implementation of Ruby has a mark-and-sweep garbage collector, while Perl uses reference counting for deterministic garbage collection -- until the interpreter thread shuts down, at which point a full sweep is performed, thus guaranteeing correct behavior of destructors even in unreachable memory. * RegularExpression''''''s is one area where Perl is far ahead of Ruby. * ThereIsMoreThanOneWayToDoIt * HereDocument''''''s * FreeSoftware * supports multiple platforms, including LinuxOs, MicrosoftWindows, MacOsx (add others if you know) * easy to write messy code that just works, supported by language and community. '''Differences''' * PerlLanguage has much stronger support for Unicode than RubyLanguage has. For example, Perl supports all Unicode properties, graphemes, and full case mapping. Ruby does not. Ruby's encoding of strings is however more explicit. * RubyLanguage is a pure ObjectOrientedProgrammingLanguage, Perl5 is less OO ''(but Perl 6 is coming with very good OO support)'', beause it believe that OO should be a programmer decision, not something forced upon you. << You don't have to use objects in Ruby, nobody is forcing you. But if you do it will be much easier to use them than in Perl. Additionally, if you use Moose/Moo from CPAN you will have more OO power available in Perl5 than in Ruby. * Both languages slightly resemble CeeLanguage, while Ruby borrows a little from SmalltalkLanguage too. * Ruby is the newer of the two, having been released in 1994, while PerlLanguage was initially released in 1987. Both are actively maintained, with Ruby having annual releases and Perl several releases per year. * There are many times more Perl users than Ruby users in both software development and systems administration. * Ruby has overtaken Perl in sheer number of third-party libraries. * Perl supports both dynamic scoping and lexical scoping. Ruby does as well, though it tends toward dynamic scoping, much like PHPLanguage. * Perl uses sigils such as @, $ and % to denote variable type, and Ruby uses sigils such as @, @@, and $ to denote scope. By default, all variables except functions in Perl require a sigil, and variables in Ruby in the most local scope don't. * Perl has multiple variable types (scalar (a "single thing", capable of holding a string, a number, or a reference), array, hash, function). 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. << You can force dereferences to specific types in Ruby. * Perl native types 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 encourages Ruby users to overload operators in non-sensical ways; for example, using "+" for both string concatenation and numeric addition, making "+" symmetric in one case but not the other. Like Perl, some methods also implicitly convert types (e.g., to_i, to_f, to_s as necessary). * Perl5's syntax for defining objects is unfamiliar to new programmers and difficult for them without modules like Moose, Mouse or Moo. Ruby's syntax more closely resembles other languages with class systems. Main reason for that is that Perl was originally not designed to be Object Oriented - OO was deftly added on top of Perl4, seamlessly reusing existing language features like packages for classes, references for objects, and subroutines for methods. ** Unless somebody does not believe in heavy OOP and likes the way the language is for non-OOP stuff. * Ruby and Perl both support first class continuations, though Ruby intends to drop this feature in version 2.0. -- As of version 2.0, Ruby still supports first class Continuations. * Perl has goto. Ruby doesn't. (Which is bad ''because?'') ---- ''Ruby is not similar to PascalLanguage other than the use of the "end" keyword. It is more similar to SmallTalk. (-- AustinZiegler)'' Apart from the curly brackets, is Perl anything like CeeLanguage? ''Of course it is! For example: constructs like "for", "while" and "if", attribution ("="), +=, ternary operator (?:), printf, sprintf'' Ruby uses a full PCRE library for regexes, so that part is virtually the same. I think Ruby '''is''' similar to Perl, but only in a broad philosophical sense. There's more than one way to do it; easy things should be easy, complex things should be possible, all that jazz. Ruby was written to meet pragmatic constraints, as was Perl. (YukihiroMatsumoto focused on weeding out ugly little inconsistencies and misfeatures as well; LarryWall was not so concerned with this.) 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 If you think ''being stuck with $_ is damned ugly'', put 'use English;' at the beginning of your program and you can say $ARG instead of $_. English.pm has been a core module for several years now; all the special variables have an English equivalent. See perldoc perlvar. -- JoePepersack I would say that Ruby and Perl share a philosophy more than they do features: ThereIsMoreThanOneWayToDoIt. For instance, to print things, you have print, p, puts, $stdout <<, etc. That these all have subtle distinctions only emphasizes the link to Perl. Ruby and PythonLanguage, on the other hand, have many similar features, but Python is much more focused on providing one mainstream way to do things. ---- After a bit of a look I got the feeling the RubyLanguage is the result of crossing PerlLanguage with SmalltalkLanguage. -- DavidPlumpton This has been my opinion since day one. Ruby = Smalltalk + Hentai Tentacles (a.k.a. Perl) * ''Reminds me of ExtraLegsOntoAdog.'' My description of Ruby has always been: Smalltalk with enough syntactic sugar that you can make it look like Perl. --RobertFisher ---- After prolonged use, I got the feeling that Ruby has little to do with PerlLanguage, save the superficial "scripting language" comparisons listed up top. -- JamesBritt See http://www.rubygarden.org/faq/entry/show/14 for a list of what RubyLanguage lifted from Perl. (It's halfway down the page) ''I also got that feeling (after a few months with Ruby). Now that I have looked at SmalltalkLanguage, Ruby feels more like a re-implementation of Smalltalk with Algol-like syntax, file/edit/command-line environment instead of the IDE, and a bunch of Perl functionality thrown in as libraries (RegularExpression''''''s, etc).'' That's what I think really 'killed' Smalltalk... the VM/VI model offers a number of interesting advantages, but in a practical sense, it can be very prohibitive. Similar logic explains why the VonNeumann architecture won out over technically sophisticated devices like the LispMachine. (Disclaimer: this is not a knock on either Lisp or Smalltalk; in all honesty, I strongly admire those two and use SBCL under SLIME.) -- TheerasakPhotha ---- With rubyisms.pm (available from TheCpan), ruby-style blocks are available in perl. By no means does this equate to feature parity, but the style is available at least. ---- See also ScriptingLanguage ---- CategoryProgrammingLanguageComparisons CategoryComparisons, etc. That these all have subtle distinctions only emphasizes the link to Perl. Ruby and PythonLanguage, on the other hand, have many similar features, but Python is much more focused on providing one mainstream way to do things. ---- After a bit of a look I got the feeling the RubyLanguage is the result of crossing PerlLanguage with SmalltalkLanguage. -- DavidPlumpton This has been my opinion since day one. Ruby = Smalltalk + Hentai Tentacles (a.k.a. Perl) * ''Reminds me of ExtraLegsOntoAdog.'' My description of Ruby has always been: Smalltalk with enough syntactic sugar that you can make it look like Perl. --RobertFisher ---- After prolonged use, I got the feeling that Ruby has little to do with PerlLanguage, save the superficial ---- ThreadMess? See KolmogorovQuotient.