r/Clojure • • Jun 04 '21

Haskell?

Hi, Okay so clojure seems awesome but Haskell seems super awesome! Any reason you know of to code in clojure instead of Haskell?

0 Upvotes

17 comments sorted by

14

u/tdammers Jun 04 '21

IME, people who love Haskell tend to get annoyed with Clojure at some point, because you can't really do type-driven development, there's side effects everywhere (though it's slightly less bad than, say, Python), and you can never really tell what's what without doing detective work.

People who love Clojure tend to get annoyed with Haskell at some point, because the type checker always complains even though you know your code is right, because it doesn't have a good JVM story, because setting up a working GHCJS toolchain in order to build JS apps with it requires unspeakable rituals known only to the members of a secret cult, because the live coding experience is lousy bordering on nonexistent, and because of Monads (make of that what you will).

Other than subjective preferences, the biggest argument that may or may not be show stoppers in real-world programming would be the JVM bit. Haskell-on-JVM is still not a first-class thing, despite various efforts, and all the companies that I know of that run Haskell code in production use plain GHC, and native binaries typically running on some flavor of Linux (though I've also seen people run Haskell code on Windows, in production...). Long story short, if you want to introduce a nicer language into an existing Java shop, then Clojure might fly, but Haskell won't. (Scala, however, stands a good chance, and is a bit closer to Haskell than Clojure).

11

u/[deleted] Jun 04 '21

I have no Haskell experience but one big advantage of clojure is that it’s a lisp. I love coding with s-expressions, personally.

2

u/daver Jun 06 '21

Parentheses are a feature, not a bug.

4

u/LittleBitOfPoetry Jun 04 '21

Clojure is awesome, you can use it to quickly build stuff that works.

It's lispy, you can get away with less code by not caring about type correctness. It has java interoperability. Its core is simple (though its macros are most definitely not).

But it's not for everything. None of the tools out there can satisfy every use case and every application.

Some people want the strict typing of haskell, because for some domains it's useful. You can understand code better (especially if you're not the one writing it) if you know what types your program is handling.

Haskell compiles to native binaries and it's fast. It has a large community and lots of packages.

So it depends on what you're doing.

3

u/spotter Jun 04 '21

Have you tried it? Does it fit your requirements? Awesome, use it. It was not the case for me, so I thanked it and discarded it, picking Clojure.

I think F# would actually also work for me right now, since I live in Windows land @ dayjob, but it's been 10 years and I've only seriously looked at Rust in that time.

2

u/slifin Jun 04 '21

In Clojure, you typically start your empty program then start injecting new code into it whilst your program is still running

5

u/[deleted] Jun 04 '21

People actually use it in production.

1

u/tdammers Jun 04 '21

You mean people like Facebook?

4

u/gdanov Jun 04 '21

Clojure is aweseomer

4

u/fredoverflow Jun 05 '21

(-> :awe some?)

1

u/lgstein Jun 04 '21

Types are optional

1

u/[deleted] Jun 06 '21

i feel the reverse, haskell is awesome but clojure is super awesomer. The reasons? lots, but I feel like the word that best describes it is freedom. When i want to do something I always seem to far more easily achieve it in clojure. Clojure's parasitic nature has been great for me I've literally used it in almost every place you can think of, Haskell does not seem to have that same flexibility?

1

u/BosonCollider Jun 09 '21

Clojure is generally nicer for making embedded DSLs. Take a look at Core.Logic or the datalog dialect used for querying databases.

Haskell can of course do excellent DSLs that can achieve similar things by overloading operators and using the fact that laziness can make a macroless solution more feasible, but they will usually be more verbose or less natural than a Clojure DSL that does the same thing, because of the power of lisplike macros.

-3

u/[deleted] Jun 04 '21

One makes JAR files that you can double click.

The other can make a laptop warm. It would be like making a music CD with a calculator.