News for hackers. Stuff that matters.
Re:Haskell vs. Clojure (2014) by bitwize on Wednesday September 14, 2016 @04:00PM (#12500727)
If you just want to get shit done, Clojure is fine (though any other Lisp would arguably be better than Clojure).

If you want to get shit done, and make sure the types are correct, and make sure all side effects are properly managed and accounted for, that's Haskell's niche.

Re:Haskell vs. Clojure (2014) by Zolomon on Wednesday September 14, 2016 @04:04PM (#12500754)
> ... Clojure is fine (though any other Lisp would arguably be better than Clojure).

Care to elaborate why you think any other Lisp is better than Clojure? I would like to hear your arguments.

Re:Haskell vs. Clojure (2014) by tsm on Wednesday September 14, 2016 @04:46PM (#12501066)
Not the GP, but for quick things I prefer CL because:

* TIMTOWTDI. Doing everything with map/reduce/filter is great, but sometimes it's more direct to just use the LOOP macro. Immutability is great, but sometimes it's way faster to just SETF something (and not have to worry about atoms).

* Batteries (more) included. IME, I find myself needing to use third-party libraries sooner with Clojure than with CL. Also, QuickLisp is arguably faster to get rolling with than Leiningen (I've found it easier to get the new library into my existing lisp image). And CL tends to have clusters of functions that do similar-but-different things, whereas Clojure puts the cognitive burden on you to do things right (example off the top of my head: CL has REMOVE, REMOVE-IF, and REMOVE-IF-NOT, Clojure has ????? (like ten different ways, I'm serious), `(filter pred list)`, and `(filter (complement pred) list)`).

* The debugging situation is fantastic. Both because CL deals with errors a lot more gracefully than Clojure (are we allowed to blame the JVM?) and because SLIME >>> CIDER, at least for now.

Re:Haskell vs. Clojure (2014) by gyim on Wednesday September 14, 2016 @05:17PM (#12501275)
I haven't used the LOOP macro in CL, but the for macro in Clojure is also very powerful and (imho) very readable.

My take on the 'versify' example in 4 lines:

    (for [book book-order
          chapter (range 1 1000) :when (get-in bible [book (str chapter)])
          verse (range 1 1000) :when (get-in bible [book (str chapter) (str verse)])]
      [book chapter verse (get-in bible [book (str chapter) (str verse)])])
Notice that a single "for" can iterate in a multi-level structure. You can also use :let if you don't want to call (get-in) multiple times (which makes the code shorter, but more redundant and less efficient)
Re:Haskell vs. Clojure (2014) by shiro on Wednesday September 14, 2016 @10:49PM (#12502975)
I use CL/Scheme/Clojure at work. I generally prefer comprehension style ('for' in Clojure, srfi-42 in Scheme) but sometimes CL's loop let me save a few nestings.

One of such patterns is when I have to accumulate multiple kind of things while I zip through the input. Somewhat contrived example: You have a hashtable that maps integer key to a list of strings. You want to scan it just once and build two lists, strings associated with odd keys and strings associated with even keys.

    ;; populate input 
    (defvar input (make-hash-table :test 'eql))
    (setf (gethash 1 input) '("ichi" "hi"))
    (setf (gethash 2 input) '("ni" "fu"))
    (setf (gethash 3 input) '("san" "mi"))
    (setf (gethash 4 input) '("yon" "shi" "yo"))
    (setf (gethash 5 input) '("go" "itsu"))

    ;; loop
    (loop for k being each hash-key in input
       when (oddp k) append (gethash k input) into odds 
       when (evenp k) append (gethash k input) into evens 
       finally (return (values odds evens)))
    ; => ("go" "itsu" "san" "mi" "ichi" "hi") and ("yon" "shi" "yo" "ni" "fu")
Re:Haskell vs. Clojure (2014) by junke on Thursday September 15, 2016 @04:20AM (#12504303)
You surely know this but for other people interested:

1. You could add "using (hash-value v)" in the iteration clause to directly have the value (no gethash).

2. There is maphash too.

Re:Haskell vs. Clojure (2014) by shiro on Thursday September 15, 2016 @06:06AM (#12504690)
Right! I tried to construct a terse example in hurry but apparently missed the mark. Usually loop comes handy when conditions and the way to extract values gets more complicated.
Re:Haskell vs. Clojure (2014) by jeletonskelly on Wednesday September 14, 2016 @07:52PM (#12502268)
How is it more direct to use loop? As someone who has been writing production clojure for nearly 5 years I usually only see loop macro used by devs coming from oop because that's a more comfortable pattern for them. I have rarely needed to use it.

As far as collections go, there's filter, remove, reduce, and various take functions. I don't see the deficiency.

Debugging is still an issue, but I personally don't find it too difficult... probably because I'm used to it.

Re:Haskell vs. Clojure (2014) by dkersten on Thursday September 15, 2016 @12:33PM (#12507555)
I believe he is referring to Common Lisp's loop, not Clojure's loop.
Re:Haskell vs. Clojure (2014) by weavejester on Wednesday September 14, 2016 @09:19PM (#12502647)
Maybe there's a better example, but REMOVE-IF sounds like Clojure's 'remove', REMOVE-IF-NOT sounds like 'filter', and REMOVE sounds like 'disj', or possibly '(remove #{item} list)'.
Re:Haskell vs. Clojure (2014) by bitwize on Wednesday September 14, 2016 @04:51PM (#12501098)
Clojure has neither the cool constructs of CL (CLOS, conditions) nor the minimal design and fantastic set of control primitives of Scheme. In fact it has no significant advantage over Scheme aside from running on the JVM, and a few disadvantages (recur, why TF are lambda lists vectors?, etc.). It's different enough to be weird and annoying, but the differences aren't advantageous enough to make me want to switch: Scheme (and CL!) has been made to run efficiently on the JVM (with some caveats, which Clojure has also!).
Re:Haskell vs. Clojure (2014) by dkersten on Thursday September 15, 2016 @12:41PM (#12507626)
recur

I actually really like recur because it signifies intent. It tells the future-me that I intended for this function to be tail recursive (ie, it not being tail-recursive should be considered an error).

Re:Haskell vs. Clojure (2014) by wtetzner on Thursday September 15, 2016 @05:15PM (#12509882)
It does, but it's still too weak, e.g. it only works if the function is calling itself.
Re:Haskell vs. Clojure (2014) by xiaomai on Wednesday September 14, 2016 @06:21PM (#12501706)
I mostly agree with you, but I think the out-of-the-box immutable data structures and sugar around around maps are very nice compared to the out-of-the-box scheme/racket experience.
Re:Haskell vs. Clojure (2014) by riboflava on Wednesday September 14, 2016 @06:42PM (#12501826)
I'm a fan of the out of the box immutable data structures and like the sugar, though you can get both in Lisp if you want. (Presumably Racket as well.) Lisp has everything, and more, though sometimes you have to work for it. I do enjoy Clojure's interop with the JVM, but that along with the community producing interesting things (this includes ClojureScript) are the primary reasons I care about Clojure at all. On the nice-to-work-with side of things I really enjoy that it was designed by one person rather than a standards committee from decades ago, it feels fresh working with it, but if you stranded me on an island and gave me one language to have for the rest of time I'd pick Lisp for its power.
Re:Haskell vs. Clojure (2014) by technomancy on Wednesday September 14, 2016 @09:21PM (#12502654)
> you can get both in Lisp if you want

The whole point of benefiting from immutable data structures is their ubiquity. If they're something you reach for only when you personally decide you need them, they're unlikely to work well with 3rd-party code; you will have to do a lot more digging to understand how the code you're writing will behave in a concurrent context vs having it be obvious. Making it opt-in is almost making it pointless, unless you never use 3rd-party code.

Re:Haskell vs. Clojure (2014) by catnaroek on Thursday September 15, 2016 @03:28AM (#12504074)
Is it possible to make truly persistent data structures in Lisp, rather than just persistent by convention? Here are some benefits that you can only get if the language implementation knows your data structures are immutable:

(0) The compiler can automatically perform optimizations like fusing small nodes and hash consing.

(1) The garbage collector can take advantage of the fact that traversing (the immutable portion of) the heap sequentially produces a topological sorting of the object graph.

Re:Haskell vs. Clojure (2014) by asciihacker on Wednesday September 14, 2016 @04:40PM (#12501030)
>If you want to get shit done, and make sure the types are correct, and make sure all side effects are properly managed and accounted for, that's Haskell's niche.

Dont Clojure's immutable types handle the side-effect issues well? Without the contortions that Haskell puts you through.

Re:Haskell vs. Clojure (2014) by tsm on Wednesday September 14, 2016 @04:53PM (#12501117)
Clojure's immutable types mean just that—the values are immutable (e.g., in CL you could do (defvar x 42) (setf x 84), but in Clojure the equivalent is not allowed).

But there are many more side effects than changing variables. Clojure makes no guarantees that a given function is referentially transparent, nor does it promise that a given function doesn't write to stdout/stderr, read from stdin, change the file system, make a network connection, send missiles to foreign countries, etcetera.

Re:Haskell vs. Clojure (2014) by sarnowski on Wednesday September 14, 2016 @05:10PM (#12501233)
Not arguing that the following method can be trusted as much as in Haskell but properly used also prevents this kind of scenario:

https://clojuredocs.org/clojure.core/io℅21

The 'io!' macro marks a code block to have side effects which prevents using it in a STM transaction as 'dosync' might need to execute the functions multiple times in case of conflicts during the optimistic locking.

Re:Haskell vs. Clojure (2014) by catnaroek on Wednesday September 14, 2016 @07:17PM (#12502038)
> properly used

In the sense C programmers use the term? Why should humans be trusted with identifying all operations that can't be safely performed within a transaction?

Re:Haskell vs. Clojure (2014) by Royalaid on Wednesday September 14, 2016 @04:11PM (#12500814)
Like my sibling commenter, I would like to know what’s wrong with clojure when compared to other LISPs