Live data from Hacker News

A difference between Haskell and Common Lisp

chrisdone.com

21–30 of 203 posts

Re: A difference between Haskell and Common Lisp

#21

You have to be clear about which Lisp. Clojure and Scheme are Lisps, and their focus is very much towards simplicity and the use of combinators. The complex, do-it-all-in-one-huge macro is a Common Lispism, not a Lispism. Secondly, Clojure, like Haskell, is focused on sequence abstractions, not lists. Sequences can include collections, streams, observables, sockets and many other kinds of process that can be modelled…

Common Lisp isn't technically focused on lists as you imply. There are plenty of libraries which provide "sequence abstractions" if that's what you need. Common Lisp provides structs, arrays, and even a hash table implementation. The methods of abstraction are transparent in Lisp.

Re: A difference between Haskell and Common Lisp

#22
I'm not sure I agree at all with the premise of this article. Languages are a syntax they don't have "Philosophies." They may have design elements that reflect or support the philosophies of their designers(e.g. functions as first class citizens), but the author doesn't provide critique on what they believe these to be instead looking at a few std lib functions that some yahoo implemented.

Look at something like java. Java has a core set of design elements. It was built by a person with some philosophical leanings("Everything is a class", "Checked/Unchecked exceptions being different things", "no first class functions") Then it has standard libraries(i/o, collections, threading/synchronization) each of these was built by a person with there own set of biases and understandings. The original Collections implementation has lots of mutable data structures then later Josh Bloch decided that he didn't like that anymore and stopped adopting "immutability" as core design philosophy. Immutability was not previously considered important when evaluating a java implementation. What you end up with is a mish mash of different opinions that only gets more different as you go.

Some 3rd party libraries like Guava didn't jibe with the Philosophical leanings of the language itself and looked for work arounds. They went as far as to create their own implementation of functions as a first class citizen in a language that was expressly designed to omit them. Some commonly used Android libraries do this as well.

My point here is that "language" can mean lots of things. It can refer to the language itself, its run time, the syntax+runtime+community. What is idiomatic and on, on, on. People and groups of people have the philosophies. I'd like to see the author point to something a little more critical about the differences between these two concepts. This premise is a little muddled.

Re: A difference between Haskell and Common Lisp

#23

Is this really a philosophical difference? Granted, I've only used Clojure as far as Lisps go, but composability seems to be something that's emphasized. Rather than (remove-if-not #'p xs :count 5 :start 3) It seems to me like most Clojure users would do something like (->> xs (drop 3) (filter p) (take 5)) which is much closer to take 5 . filter p . drop 3

Clojure, and to a slightly lesser extent scheme, are much more Haskell-like than common lisp or emacs lisp.

Clojure of course has pattern matching and lazy sequences, so naturally for collections it is very compatible with Haskell's philosophy.

Re: A difference between Haskell and Common Lisp

#24

Is this really a philosophical difference? Granted, I've only used Clojure as far as Lisps go, but composability seems to be something that's emphasized. Rather than (remove-if-not #'p xs :count 5 :start 3) It seems to me like most Clojure users would do something like (->> xs (drop 3) (filter p) (take 5)) which is much closer to take 5 . filter p . drop 3

My first contact with programming (besides BASIC) was (auto)lisp. It was kind of a first love: every language I tried after Lisp was a disappointment. Then I found Haskell..

A bit off topic: interesting link with project euler solutions written in haskell and clojure (and sometimes other languages). With execution time log.

http://zach.se/project-euler-solutions/

Re: A difference between Haskell and Common Lisp

#26

Is this really a philosophical difference? Granted, I've only used Clojure as far as Lisps go, but composability seems to be something that's emphasized. Rather than (remove-if-not #'p xs :count 5 :start 3) It seems to me like most Clojure users would do something like (->> xs (drop 3) (filter p) (take 5)) which is much closer to take 5 . filter p . drop 3

Minor nitpick. Technically, this: #(->> % (drop 3) (filter p) (take 5)) Is equivalent to: take 5 . filter p . drop 3

One could also change the Haskell. Data.Function (&); Control.Arrow (>>>)

  -- the pipe operator seems to be all the rage these days
  (|>) = (&)
  
  -- forward application + forward composition
  xs |> (drop 3 >>> filter p >>> take 5)
Only function application

  xs |> drop 3 |> filter p |> take 5

Re: A difference between Haskell and Common Lisp

#27

Is this really a philosophical difference? Granted, I've only used Clojure as far as Lisps go, but composability seems to be something that's emphasized. Rather than (remove-if-not #'p xs :count 5 :start 3) It seems to me like most Clojure users would do something like (->> xs (drop 3) (filter p) (take 5)) which is much closer to take 5 . filter p . drop 3

Is not the same, in lisp :count 5 means that you remove at most 5 elements, so that the result can be a list of 100 elements, while take 5 will always produce a sequence with at most 5 elements.

(remove-if-not #'evenp (loop for i below 10 collect i) :count 3 :start 0) result is (0 2 4 6 7 8 9), there are three elements deleted.

Re: A difference between Haskell and Common Lisp

#28
Perhaps it's just me, but I don't see that Haskell and Lisp are that similar, other than...

1. They're both programming languages.

2. They both allow you to pass functions as arguments to other functions.

Am I missing something here? Why are the two linked? Is it because Lisp is seen as the birthplace of functional languages (because of point 2)?

Re: A difference between Haskell and Common Lisp

#30
Actually Common Lisp supports a gazillion of different programming styles.

The version with small functions, similar to the Haskell version:

    (subseq
     (remove-if
      (complement #'numberp)
      (butlast list 3))
     0 5)
In above Common Lisp code, we use four different functions which do one task:

    * subseq sequence start &optional end => subsequence
    * remove-if test sequence => result-sequence
    * complement function => complement-function
    * butlast list &optional n => result-list


For different approaches see Common Lisp libraries like Series or Iterate... Iterate is LOOP on steroids.

http://series.sourceforge.net

https://common-lisp.net/project/iterate/

> This is known as composability, or the UNIX philosophy. In Lisp a procedure tends to accept many options which configure its behaviour.

Check out the UNIX man for tail, grep, ... to see how strange above quote about 'unix philosophy' is. In reality Unix commands are programs with obscene amount of configuration options, sometimes piping data as text around, sometimes glued together by strange shell languages...

Post reply on HN