Live data from Hacker News

A philosophical difference between Haskell and Lisp (2015)

chrisdone.com

51–60 of 181 posts

Re: A philosophical difference between Haskell and Lisp (2015)

#51

Earlier quoted context omitted.

Is there something similar to (->>) in Haskell? Edit: corrected “—>”.

I think there are some pipe-like operators in the popular Lens library (and presumably others as well). However, writing Haskell, you quickly get used to everything being backwards.

I find the Lens operators in Haskell just the most hilarious API in all of computing, even knowing that there is some sense to it.

Re: A philosophical difference between Haskell and Lisp (2015)

#52

I dislike the lisp convention of remove-if, remove-if-not, etc. Filter and take isn't much better. The python convention is much nicer: [x for x in foo if x not in y] Turns out, this can be expressed in Lisp: (list x for x in foo if x not in y) I've implemented this into my fork of Lumen that runs on Python. https://github.com/shawwn/pymen It feels very nice to use: > (list x for x in (range 10) if (= (% x 2) 0)) """…

It is also ~20 lines in CL http://lisp-univ-etc.blogspot.com/2013/01/real-list-comprehe...

But list comprehensions suffer from the same problem the author is taking about, they don't compose. Its even worse than CL remove-if variant, where one can reify the filter into a function that can then compose.

Re: A philosophical difference between Haskell and Lisp (2015)

#53

Earlier quoted context omitted.

I followed a (pure) mathematics education, and I totally dig lisp. On the other hand, I abhor haskell and hate almost everything about it!

This comment would be more informative if you briefly explained why you abhor it and hate almost everything about it.

Yep, sorry.

This is a matter of feeling, completely irrational, but just my experience.

When I program in lisp I get the same feeling when I'm solving an ODE by hand, or a Diophantine equation, or designing a numerical method to approximate the solution of a PDE, or finding the Euler-Lagrange equations of a physical problem. The thing is real and it gets shit done really fast; it is just exhilarating. Moreover, lisp macros are so dirty and fun that using them feels like kinky sex.

Haskell is like category theory. Sure, it is pure and general, and you can create set theory and the rest of math from it. But it is certainly the most boring thing that I can think about.

But hey, whatever floats your boat.

Re: A philosophical difference between Haskell and Lisp (2015)

#54
post #48

A small note: composition is not better than monolithism. The article makes it feel like it is but it is not. They are two perfectly valid approaches when it comes to solving problems. Often a mix of both is used. Monoliths tend to be better at solving common real life problems efficiently while composition is better suited for unexpected abstract problems. We need both. For example GNU binutils are not very "unixy",…

I disagree. With composition we have general building blocks which can be combined in an infinity of ways, and remain available to combine with newly added functions. The monolith way provides a fixed, non upgradable set of possibilities, so if your need does not fall into what already exists you need to add yet another monolith (see remove-if vs remove-if-not).

Re: A philosophical difference between Haskell and Lisp (2015)

#55
post #6
post #3

Any particular reason why Lisp doesn't also tend to compose with smaller functions? Did it just happen to evolve that way? Is it easier to get the types of the smaller functions right when you have a compiler to help you like you do in Haskell?

Clojure takes that approach

How do Clojure transducers compare to Haskell's stream fusion in 2020?

Re: A philosophical difference between Haskell and Lisp (2015)

#56

I dislike the lisp convention of remove-if, remove-if-not, etc. Filter and take isn't much better. The python convention is much nicer: [x for x in foo if x not in y] Turns out, this can be expressed in Lisp: (list x for x in foo if x not in y) I've implemented this into my fork of Lumen that runs on Python. https://github.com/shawwn/pymen It feels very nice to use: > (list x for x in (range 10) if (= (% x 2) 0)) """…

For those that didn't know, Haskell does of course have list comprehensions: [x| x Here's an example finding consonants: [c| x

No need for the dollar sign in the second example :)

A nice thing about Haskell list comprehensions is they're based on a trivial transformation to monad syntax, which makes it easier to factor out complex list transformations into multiple little bites. I've run into this problem in Python. Also, Python list comprehensions can often behave very unexpectedly due to mutability.

Here's an example of the monad syntax:

    [(x,y) | x 
equiv

    do
      x 
Lots of combinatorics problems can be elegantly solved using the list monad like that.

Re: A philosophical difference between Haskell and Lisp (2015)

#57
post #3

Any particular reason why Lisp doesn't also tend to compose with smaller functions? Did it just happen to evolve that way? Is it easier to get the types of the smaller functions right when you have a compiler to help you like you do in Haskell?

Impurity plays poorly with function composition. cf "value restriction".

Re: A philosophical difference between Haskell and Lisp (2015)

#58

Earlier quoted context omitted.

This comment would be more informative if you briefly explained why you abhor it and hate almost everything about it.

Yep, sorry. This is a matter of feeling, completely irrational, but just my experience. When I program in lisp I get the same feeling when I'm solving an ODE by hand, or a Diophantine equation, or designing a numerical method to approximate the solution of a PDE, or finding the Euler-Lagrange equations of a physical problem. The thing is real and it gets shit done really fast; it is just exhilarating. Moreover, lisp…

Sounds more like applied math...

Re: A philosophical difference between Haskell and Lisp (2015)

#59
The LOOP macro is actually a very different approach: it's an embedded domain specific language for iteration tasks. The language is thought to be more natural (-> 'conversational') than formal -> an actual influence from Interlisp, where this macro originally came from.

If we talk about the approach of using larger building blocks with named parameters, that's also typical in UNIX, since most UNIX commands have zillions of named arguments, even more so than typical Common Lisp functions. Typically it is easier in using interactive command languages to fill out common options to a command, than to write programs.

For example 'ls' does not expose a bunch of functions to combine, but is a powerful command with lots of named options:

https://man7.org/linux/man-pages/man1/ls.1.html

Named parameters/arguments are not generally common in Lisp. Emacs Lisp did not have them and wanted to avoid them explicitly.

Re: A philosophical difference between Haskell and Lisp (2015)

#60
This seems to imply that extensive use of composition in Haskell is a notable stylistic decision rather than an entailed effect of the fundamental design choices (first-class functions, lazy evaluation, type classes) that explicitly encourage such composition and a terse, mathematical syntax that makes the composition operation obvious.

Heavy use of Composition is idiomatic in lisps, too. It’s just the syntax doesn’t rub your face in it: It’s pretty common to see form in lisp that ends in a dozen close-parentheses as we see chains of forms being passed as arguments to other forms. It would be weird if composition wasn’t idiomatic in a language with first-class functions.

The loop macro isn’t good evidence: it’s notable precisely because of its difference from typical lisp usage. I’ve heard lisp programmers claim to refuse to use loop because it clashes with the rest of the language. I’m less interested in purity, and it is so convenient sometimes...if only as a clear illustration of just how much power and potential for abuse the CL macro system provides. Amd let’s just leave CLOS and metaobject protocols under the tarp for now :-)

Post reply on HN