News for hackers. Stuff that matters.
Re:Practicality: PHP vs Lisp by eru on Friday July 02, 2010 @12:22PM (#1481512)
I find e.g. closures in Lisp overly verbose. The ML family of languages has a much lighter weight syntax for functions. This makes amazing stuff look less like code for code's sake.

(Though I do admit that I immensely like Lisp's macros.)

In e.g. Haskell abstractions are the straightforward way to solve a problem. Abstractions are cheap.

Re:Practicality: PHP vs Lisp by Zak on Friday July 02, 2010 @10:59PM (#1483113)
Closures in most Lisps are a bit verbose, but it's easy to create an alternate syntax using a macro. Arc and Clojure provide built-in shorthand for function literals that makes them much more convenient to use.
Re:Practicality: PHP vs Lisp by eru on Saturday July 03, 2010 @12:06AM (#1483222)
Indeed. Though with variable arity (which can be a good thing!), currying will always be at least slightly more cumbersome than in languages with fixed arity of the ML type syntax for function application.

Currying and combinators are my preferred ways of creating new functions. Having infix symbols can help a bit, but I don't see it as crucial.

Incidentally I only really began to use reduce/fold in Clean and Haskell, though I had been exposed to the concept in Scheme before, and used it a few times. But perhaps that was just a learning effect of prolonged exposure and would have happened while staying with Scheme, too.

I still like Scheme. Matthias Felleisen is doing great work using it for education.

Re:Practicality: PHP vs Lisp by jockc on Saturday July 03, 2010 @02:06AM (#1483381)
Verbose how?
Re:Practicality: PHP vs Lisp by eru on Saturday July 03, 2010 @05:41AM (#1483587)
Partial application is slightly harder to do in Lisp.

Compare:

  (define (list-reverse l) (foldl cons '() l))

  listReverse = foldl (flip (:)) []
I hope both versions are fairly idiomatic.

Here are two combinators that I have actually used in my code (the first one is fairly common):

  dot :: (b -> c) -> (a1 -> a2 -> b) -> a1 -> a2 -> c
  dot = ((.).(.))
  swing :: (((a -> b) -> b) -> c -> d) -> c -> a -> d
  swing = flip . (. flip id)
Imagine (or better: provide!) Scheme versions or their idiomatic equivalents.

Of course the point-free definitions makes them a bit hard to understand, but I wanted to demonstrate terseness. `dot' also has a nice point-full definition:

  dot f g a b = f (g a b)
The use case for `dot' should be obvious from the latter definition. I leave the point-full definition (and a use case) for `swing' as an exercise. Let me just note that Lisp would carry some more syntactic baggage for the definition and use of both of these combinators.

However, you can't beat Lisp, when it comes to Quines:

  ((lambda (x) `(,x ',x)) '(lambda (x) `(,x ',x)))
Haskell's facilities for talking about Haskell code are more verbose.

P.S. for completeness sake, to make the exercise above easier without doing a search:

  id a = a
  flip f a b = f b a