Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As someone learning both Perl and Lisp right now, I'm going to disagree on mere cosmetics as the main thing that scares people away. I'd also disagree that the reasons people get scared away are the same for each language. Perl is scary because there's loads of arbitrary syntax and shortcuts that you have to memorize. Lisp is scary because there are some unusual concepts that need to be learned before you can accomplish anything useful.

When learning Perl, I often find myself thinking "how do I do X?" Then I go look up the trick to doing X. When learning Lisp, I find myself thinking "I know I'll be able to do X, once I understand these rudiments well."

Consider the accumulator generator: http://www.paulgraham.com/accgen.html.

How would you assign the generated accumulator function to a variable and call it?

In Perl, you look up the syntax for assigning the returned function to a variable(or just guess and you'll probably be right). Then, you look up the syntax for calling the stored function (if you guess you'll probably be wrong).

    $s = foo(5);

    &$s(1);
    &$s(1);
    $s->(1);
In common lisp (I used CLISP), you can copy the Perl way of just using a value assignment, then using the apply or funcall function to call the stored function. This is all in Chapter 2 of On Lisp

    (setq s (foo 5))

    (apply s '(1)) 
    (apply s '(1)) 
    (funcall s 1) 
Or, you can learn how to assign using symbol-function, and then you'll be able to call stored function like any other:

    (setf (symbol-function 's) (foo 5))

    (s 1) 
    (s 1) 
In Python, just guess and you'll be right:

    s = foo(5)

    s(1)
    s(1)
In my opinion, the Python version is by far the most intuitive. Call the function, assign the result to a variable, which is then callable like any other function. Lisp is more flexible and fun but takes more time to understand some aspects of the underlying interpreter. Perl is almost just like Python except I have to remember to put the right ASCII characters around my variables to get the right behavior. There doesn't seem to be a way to call a stored function just like you'd call any other function in the language. You'll always need that ampersand or the arrow. That's really annoying, just like it was really annoying in BASIC to have to use "CALL" to call a subroutine, and how you need wrapper objects in Java to call any Method. Maybe there is a way to do it, but it's probably completely random and buried in the documentation somewhere.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: