7 ms·
Hello Haskell, Goodbye Lisp
- critic 18y agoWell written article, but it would be more relevant, IMHO if it compared Haskell and Clojure, not CL.
- newt0311 18y agoNot really, the criticism apply in both cases. The main area where clojure wins against CL is that clojure is not bloated and that wasn't where the author of the article had major problems. Also, to his additions, I would like to add in the lack of decent data-structures in lisp. Cons cells are nice but they are no match for algebraic data-types and pattern matching.
- j2d2 18y agoYou must be new here...
- deleted 18y ago[deleted]
- andreyf 18y agoNot really, the criticism apply in both cases. The main area where clojure wins against CL is that clojure is not bloated and that wasn't where the author of the article had major problems. Also, to his additions, I would like to add in the lack of decent data-structures in lisp. Cons cells are nice but they are no match for algebraic data-types and pattern matching.
- jrockway 18y agoCons cells are nice but they are no match for algebraic data-types and pattern matching But of course, with a dynamic type system, objects are basically the same thing. In CL, you can encapsulate data inside its own type, and then match on that type. (It also has super/sub-typing relationships, which Haskell does not.)
- JulianMorrison 18y agoHaskell does have interface inheritance with type classes.
- jrockway 18y agoThis is more like trait composition (1) than inheritance. I don't consider this a downside, though, as I almost always choose trait composition over sub-typing when I am using a more OO-ish language. (1) http://www.iam.unibe.ch/~scg/Research/Traits/ http://www.iam.unibe.ch/~scg/Research/Traits/
- mdemare 18y agoClojure has great support for parallellism, and Clojure's community is very friendly. Haskell has nothing on Clojure in these specific regards.
- dons 18y agoIn support for paralleliism or a friendly community? I'd have thought it has both in truck loads. Well tested, fast parallelism, that's stood up to 15 years of testing...
- jrockway 18y agoWhy do you think this? Haskell not only has a friendly IRC channel, it also has friendly tools for interacting with the community. For example, it is very nice to hear someone talking about Yi, type "cabal install yi", and then having it installed and running in just a few moments. (It is also very nice to pull the xmonad darcs and say "cabal install" to install the newest version of xmonad. I don't even bother with Debian packages for anything related to Haskell anymore.) Anyway, my point is, I think you should try Haskell before you talk about it.
- chancho 18y agoAs a longtime GHC user and sometime #haskell visitor, I find your troll HILARIOUS. One thing though, you forgot "Clojure has a better library of persistent data structures." That would have sent dons into an epic flameout.
- 18y ago
- JulianMorrison 18y agoClojure completely erases the parallelism section as a complaint (although to be fair GHC is the unchallenged fastest parallel gun in the west, but contrary to the article, so far as I know even GHC never just guesses parallelism without being asked). Data structures, you mean like hashmap, vector, list, sequence? Those are all basic in Clojure. You can de-structure them within the parameter list of a function or a let, which is about half of what pattern matching is used for in Haskell. (There are also streams, but those are a bit more fuss, and they're experimental.)
- anamax 18y ago> Data structures, you mean like hashmap, vector, list, sequence? Those are all basic in Clojure. And CL...
- glymor 18y agoYou can use the same car, map on any of them as the functions operate on a sequence interface not on cons lists. Whereas in CL these functions are defined directly on the implementation (cons lists) so map can't map over a vector you need to make a special vector only map and so on.
- anamax 18y ago> Whereas in CL these functions are defined directly on the implementation (cons lists) so map can't map over a vector you need to make a special vector only map and so on. Wrong. The Common Lisp list functions, such as mapcar, are restricted to lists but Commmon Lisp also has sequence functions which take any Common Lisp sequence type. Common Lisp's map happens to be a sequence function. I forget if hashes are a Common lisp sequence type, but vectors definitely are. IIRC, Common Lisp strings are sequences.
- glymor 18y agomapcar in clojure wouldn't be limited to lists even if no one had though about the it at the time - this is the difference. There's a ton of CL code out there that only works on cons lists, adding a sequence type doesn't solve this nor does it force people to use it or change existing code.
- deleted 18y ago[deleted]
- glymor 18y agoClojure's object system: http://clojure.org/runtime_polymorphism http://clojure.org/runtime_polymorphism
- DenisM 18y agoIs there analog to List macros in Haskell? edit: yes, there is! http://www.haskell.org/th/ http://www.haskell.org/th/
- shrughes 18y agoA lot of (but not all of) what you end up getting from Lisp macros ends up being not needed to be implemented with macros in Haskell anyway.
- mattrepl 18y agoI've noticed the same thing with Clojure. I only dig into macros to remove boilerplate, like when using APIs provided in other JVM languages.
- swannodette 18y agoI've been using macros in Clojure to write my own object system. It seems to me that for serious meta-programming in Haskell, you have to use Template Haskell, and from what I've heard, it's not nearly as flexible.
- jrockway 18y agoIt seems to me that for serious meta-programming in Haskell, you have to use Template Haskell, and from what I've heard, it's not nearly as flexible. "seems" and "heard" is the best you can do? Try it, and you'll find that it's very easy to meta-program in Haskell, even without macros.
- ntoshev 18y agoCan you give an example of something you can implement with a Lisp macro, but you can't implement with Haskell?
- jrockway 18y agoSure. Consider the case of defining an instance of a type class: instance Foo Bar where quux = quuxifyBar -- terrible example Now, you want to follow the same pattern to declare "Foo Baz", "Foo Quux" and "Foo CannedAir". I hope you like copying and pasting, because that's how you do it without Template Haksell. In Lisp, it would be a simple matter of writing a macro, like this: (defmacro make-my-type-thing (type) `(instance Foo ,type ((quux (x) (,(intern (format nil "quuxify-~A" type)) x))))) Then you can: (eval-when (:compile-toplevel) (loop for i in '(Bar Baz Quux CannedAir) do (make-my-type-thing i))) Yes, the example is very contrived, and yes, Haskell ships with a lot of abstractions to make this case very uncommon. But in Haskell, you just can't treat your code as data -- it's code.
- ntoshev 18y agoIs the "parallelism" section theoretical, or you can get the Haskell compiler to actually generate multi-core code automatically?
- dons 18y agoNo, its not theoretical. However, do not assume the Haskell compiler automatically parallelises arbitrary non-parallel code. That's simply not possible to do well, and is really a dead end. What GHC does do is semi-implicit multicore parallelism for particular subsets of the language. The GHC runtime is a parallel runtime supporting a range of parallel abstractions from semi-implicit parallelism to explicit task parallelism, in a three level hierarchy of OS threads -> Haskell lightweight threads -> fine grained thread sparks. The most automated mechanisms are: * thread sparks - you hint which code to run in parallel with `par`, and the runtime uses that hint to parallelise your code, distributing it across cores. * data parallel arrays - if your algorithm is expressible as an array program, use DPH and the array operations will be automatically parallelised (alpha!) To more explicit paralelism with: * threads * transactional memory * mvars * message passing An example of the semi-implicit multicore parallelism is given in the "Haskell in 5 minutes" tutorial here: http://haskell.org/haskellwiki/Haskell_in_5_steps#Write_your_first_parallel_Haskell_program http://haskell.org/haskellwiki/Haskell_in_5_steps#Write_your...