in reply to Perl's functional features compared with Ruby

I believe the passage you're referring to from Higher Order Perl is this one:

If you pick up a good book about Lisp, there will be a section that describes Lisp's good features. For example, the book Paradigms of Artificial Intelligence Programming, by Peter Norvig, includes a section titled What Makes Lisp Different? that describes seven features of Lisp. Perl shares six of these features; C shares none of them. There are big, important features, features like first-class functions, dynamic access to the symbol table, and automatic storage management. Lisp programmers have been using these features since 1957. They know a lot about how to use these language features in powerful ways. If Perl programmers can find out the things that Lisp programmers already know, they will learn a lot of things that will make their Perl programming jobs easier.

In that passage MJD mentions seven features of Lisp. He enumerates three of them as "big" features:

I don't know Ruby, so I would have to ask someone who does (and it sounds like you've spent more time with it than I have): Does Ruby have First Class Functions? The table on the Wikipedia page to which I linked seems to indicate that Ruby's semantics don't provide as much flexibility in this regard as Perl.

The next one is "dynamic access to the symbol table". I'm hesitant to say that Ruby doesn't provide full access to the symbol table, but this StackOverflow answer seems to indicate that there is a certain degree of introspection available, and I believe there's an equivalent to symbolic references in Ruby. I don't know if it rises to the level of flexibility (and danger) that Perl provides, but it might, and someone who knows Ruby better could say for sure.

The last one is automatic storage management. Perl is a reference counting language. So is Ruby. Both will have the potential for trouble with circular references.

At one point I was interested in what the other categories were, so I looked for the book that MJD refers to. Here's the list, copied word for word from the book:

(The list is actually eight, including History.)

Uniform Syntax was interesting to me. I found this article from drdobbs that demonstrated what that refers to, and guess what? Perl has that (it's how we do objects).

Dynamic typing is a no-brainer; of course Perl has dynamic typing. Built-in support for lists: I think the swap idiom demonstrates that: ( $b, $a ) = ( $a, $b );, though Lisp seems to take this support to an impressive level. Interactive environment? Well, not like Lisp, but we do have Repl's available. ...but not like Lisp, and I doubt there are many languages that do it to the degree that Lisp does. Extensability: We have the ability to pull in modules and classes. Modules can have their own namespaces, or they can infect other namespaces if we want them to. We have XS. Perl is pretty extensible, but Lisp is designed such that extensibility is the only way to actually accomplish anything. A Lisp program is the art of manipulating the syntax tree. Perl possesses some of the extensibility features, but again Lisp is on a whole different level.

As for history, it's hard to compete with a language that's been around since the 50's.

So now that you have the complete list, you can do your research and report back to us on how Ruby fares against Lisp, and against Perl's Lispy strengths.


Dave

Replies are listed 'Best First'.
Re^2: Perl's functional features compared with Ruby
by LanX (Saint) on Jan 17, 2014 at 17:13 UTC
    > Built-in support for lists: I think the swap idiom demonstrates that: ( $b, $a ) = ( $a, $b );, though Lisp seems to take this support to an impressive level.

    I think here you are falling into a definition trap!

    You are showing a Perl list assignment...

    But IMHO in LISP-context list mostly means linked list, Perl doesn't support this datatype cause most features can be efficiently mimicked with it's arrays (push, pop, ...).

    You may remember that MJD simulated linked lists in his book with chained arrays of two element [$value,$a_ref] where $a_ref always pointing to the next chain link.

    One advantage of linked lists over arrays come when splitting them for concurrent processing.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      It's possible that I don't know what I don't know. ;) ...or that I don't know enough about what "built-in support for lists" means to two different authors coming from different language backgrounds, so you're probably right that I'm falling into a definition trap.

      There are enough fundamental differences between the two languages that paradigms differ, so it's hard to pin down exactly how their features overlap. I suspect that MJD's opinion would differ from Norvig, and I can't hope to bring them together.


      Dave