Earlier quoted context omitted.
> ... 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.
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: Sch…
Haskell vs. Clojure (2014)
31–40 of 55 posts
Re: Haskell vs. Clojure (2014)
#32Re: Haskell vs. Clojure (2014)
#33Earlier quoted context omitted.
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: Sch…
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)
#34 flatten :: ByteString -> [ (String, Int, Int, String) ]
flatten json = case decode json of
Nothing -> []
-- Type inference here can infer that we're using `val` as
-- :: HashMap String (HashMap String (HashMap String String))
Just val ->
let books = ["Genesis", "Exodus" {- ...and so forth -} ]
in [ (book, chNum, vsNum, verse)
-- for every book in the list of books...
| book
Okay, this isn't as type-safe or signed-in-triplicate as the supplied Haskell solution, but if we're comparing size-to-size, then this is pretty terse while also avoiding partial functions (the supplied Haskell solution uses read, which can throw an error if we happen to have a non-numeric key in the wrong place) and still working within the restrictions of what was given.Re: Haskell vs. Clojure (2014)
#35Earlier quoted context omitted.
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 syste…
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.
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)
#36Re: Haskell vs. Clojure (2014)
#37Re: Haskell vs. Clojure (2014)
#38Earlier quoted context omitted.
> ... 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.
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, QuickL…
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)
#39flatten :: ByteString -> [ (String, Int, Int, String) ] flatten json = case decode json of Nothing -> [] -- Type inference here can infer that we're using `val` as -- :: HashMap String (HashMap String (HashMap String String)) Just val -> let books = ["Genesis", "Exodus" {- ...and so forth -} ] in [ (book, chNum, vsNum, verse) -- for every book in the list of books... | book Okay, this isn't as type-safe or signed-in-…
Re: Haskell vs. Clojure (2014)
#40 #!/usr/bin/env amm
import $ivy.`io.circe::circe-core:0.5.1`
import $ivy.`io.circe::circe-generic:0.5.1`
import $ivy.`io.circe::circe-parser:0.5.1`
import io.circe._, io.circe.generic.auto._, io.circe.parser._, io.circe.syntax._
val bookOrder = Array("Genesis", "Exodus", /* and so forth */).zipWithIndex.toMap
type Bible = Map[String, Map[Int, Map[Int, String]]]
val bible = /* load the json file */
decode[Bible](bible).map { parse =>
(
for {
(bookName, book)
(bookOrder.get(b._1), b._2, b._3, b._4)
}
}.foreach(_.foreach(println))