Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How can you identify the problem if you first don't learn Haskell?

How would you even decide you want to learn Rust and not Haskell if you didn't know either? Hype? Popularity? Because your coworkers know Rust, or the codebase is in Rust? Those are all good reasons, honestly! So if you were in a Haskell shop, you'd have reason to prefer Haskell over Rust. There's your answer. Either will be better than Python for a medium/large project, but likely worse for a really tiny script or program.

How did you pick Python over Ruby? They are very similar, yet they have many differences. Think about it, and there's another answer for you.



If you're asking people to learn Haskell in order to find out which kinds of programs it's better on, that's a tough ask in a universe that has dozens of languages that one could learn. Most people aren't going to bite on that. No, tell us what kinds of problems it's good for, and if we care about those kinds of problems, then we'll consider Haskell.


> No, tell us what kinds of problems it's good for, and if we care about those kinds of problems, then we'll consider Haskell.

Haskell is good for writing general purpose code in the Functional Programming style [1]. It's not the only language that supports this style, but it's one of the most opinionated about keeping to this style that is also general-purpose, pragmatic, and has some industry adoption [2]. You can also see read what wiki.haskell.org has to say [3].

[1] "Why Functional Programming Matters": https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.p...

[2] Commercial Haskell: https://github.com/commercialhaskell/commercialhaskell#readm...

[3] "Why use Haskell": https://wiki.haskell.org/Introduction#Why_use_Haskell.3F

> If you're asking people to learn Haskell in order to find out which kinds of programs it's better on

I'm not asking people to do anything, but if they do want to understand the tradeoffs of any technology, sometimes the only way is the hard way: learning it. I find all too often what people really want to know is a quick and easy glance at how much language X differs from something they already know (usually C derivatives, or Java, or Javascript, or Python).


Again, I find this answer somewhat evasive. Many languages support functional programming and are used commercially. You still have not told us: What problems is Haskell best for? What is its comparative advantage?

I don't think it's unreasonable to expect a more concrete reply to that quesiton than "First master the language, then figure it out."


From my experience it is a pretty tough question to answer. You can point people to various 'smaller' aspects (like I did above regarding error handling) and try to explain why Haskell's approach is 'better' compared to other languages. But doing that for a complete, real-world problem is a lot more difficult.

I've learned Haskell and used it for a relatively long time until I finally understood what is so nice about it. Again, very hard to explain, and a lot of that comes just from the combination of simple, functional language features. Like: how currying works together with function composition; how sum-types and product-types make it easy to model your domain / problem and using pattern matching to write code that is easy to understand and does the right thing; how a powerful type-system can be leveraged to rule certain bugs out almost completely, right from the design phase. Leveraging monads by using Haskell's special `do` syntax.

I only really understood this after having done imperative style programming, then having done functional style programming, and then trying to apply the functional style in an imperative environment and seeing why it does not work there (typically because of some missing language feature).

Edit: Just wanted to point out, I am not a fan of Haskell as a whole, since there are a lot of drawbacks in my opinion. There are valuable things to learn from the language, but I do think Rust is superior.


> You still have not told us: What problems is Haskell best for?

Let me be honest here and say I don't find your tone helpful. "You still haven't told us" makes you sound as if you're in a group, critiquing from the tribune. This isn't helpful for honest conversations. There's no "us", there's just you, and I don't owe you any explanation.

That said, I provided plenty of links in my answer above, which address at least some of your questions. Have you read them? The site https://www.haskell.org has plenty of testimonials that you could also read to figure why some shops and people have chosen Haskell.

Maybe you could send Simon Peyton Jones an email, he's one of the friendliest guys in the software industry. I don't think I've ever read or heard him say anything dismissive about any other person or technology.


I'm sorry, I don't want to be adversarial or dismissive. It's just that I've been asking a very specific and precise question, and you keep replying to the question but do not answer it. This is a little frustrating!


But I did answer it, more than once and with links you can read!

What I cannot do: provide you with a single sentence stating why you should use Haskell. I don't think anyone can. For the record, I found your single sentence about Rust totally unconvincing as well; I do find Rust compelling because of tutorials, long articles I read about it, and a workshop I once did with a Rust practitioner. None of this is equivalent to debating/convincing on HN.

(Similarly, I find Go not compelling because I had to use it for my day job and everything about it made me chafe).

So my advice to you: read the links I provided, and keep in mind they are just a starting point. Do a workshop. Work on a midsize problem, maybe also write some Advent of Code Haskell solutions.

Or not. It's ok to just go with your gut feeling and focus on Rust. There's a finite amount of time you have available for exploring technologies. Rust will serve you well.


The question was: For what problem (or problem domain) is Haskell better than Rust? (Back here, for instance: https://news.ycombinator.com/item?id=29595022).

The links you gave provide general information about Haskell, but do not answer that question, from what I can see. I don't want a single sentence reason, just a compelling one.

Again: I'm not doing this to be adversarial. A decent number of people seem to really love Haskell and extol its virtues. So I'm trying to carefully check that I'm not missing something.


> The question was: For what problem (or problem domain) is Haskell better than Rust?

Haskell is a general purpose language, so it's good for any domain well served by a general purpose language. The rest is the list of benefits of statically typed, lazy first, pure functional programming languages.

"Haskell or Rust?" is not a question that can be meaningfully and objectively answered in a comment on HN.


No, he kind of did answer it. "General purpose code". He didn't say "it's for web programming" or "it's for hard real time" or "it's for numeric analysis". I mean, you can probably write web programs in Haskell, but if that's what you're trying to do, you might reach for something else. Same for numerical analysis. For hard real time you would almost certainly reach for something else. But if your program doesn't fit in a "use something specialized" category, and you want to write in a functional style, then consider Haskell. That seems to me to be a perfectly reasonable answer.

And the rest of the answer is, essentially, "beyond that, if you want to see, you're going to have to learn it". I also don't find that unreasonable - there's only so much you can explain to someone who doesn't know the language. And that's not just Haskell, that's any language. I kind of have an idea of what Rust is about, but if I want to really understand it, I'm going to have to learn it. Same with Haskell, or Lisp, or pretty much anything.

So I found the_af's answer to be quite helpful. And I'm the guy who asked the question, so...


How do I decide? I look at the features and documentation for each language, and try to figure out what problems it is best suited for. I also ask various people I trust (and HN commenters!).

I agree: If the problem is "How do I get paid?" and the best available job requires learning Haskell, then learn Haskell!

But, I think this is kind of an evasive answer. First, not many jobs require Haskell, so if my choice of language is dictated by economic concerns I'm better off with, say, Python or various web dev stacks. Second, because I have in mind a situation in which the implementer has a fixed problem and is trying to figure out which language to use. (A personal project, say.) I'm sorry if this was not clear.

So, I ask again: are there any problems for which Haskell is a better solution than Rust?

edit: Regarding the Ruby question, I think the language has various flaws, but going into detail would take way too time. A shorter answer is: numpy, scipy, pytorch, numba.


> I look at the features and documentation for each language, and try to figure out what problems it is best suited for

Well, and what have you found so far in relation to Rust and Haskell? It seems to me you know what you have to do.

Let's assume your answer is "I read every introductory page in wiki.haskell.org, read and worked through a couple of tutorials, and I still cannot figure it out". If so, do you think a comment here in HN is going to convince you of picking language X over Y?

> So, I ask again: are there any problems for which Haskell is a better solution than Rust?

Realistically, which kind of answer do you expect? A summary of the "Why Haskell" and "Why Rust" pages? I'm sure they exist and you could take a look at them and decide.


> If so, do you think a comment here in HN is going to convince you of picking language X over Y?

Yes. Because I'm a highly fallible person and very open to the idea that a Haskell expert might be able to point out a good use case that I missed.

> Realistically, which kind of answer do you expect? A summary of the "Why Haskell" and "Why Rust" pages? I'm sure they exist and you could take a look at them and decide.

The selling point of Rust is (very, very) roughly "C++ without the bad parts, and some more good parts." Given the demonstrated utility of C++ (and demonstrated pitfalls) this is manifestly appealing. Avoiding memory safety related security holes alone is huge.

That's an example of the kind of answer I expect.


> a Haskell expert

I'm not a Haskell expert, I just dabbled with it and liked it.

> The selling point of Rust is (very, very) roughly "C++ without the bad parts, and some more good parts." Given the demonstrated utility of C++ (and demonstrated pitfalls) this is manifestly appealing. Avoiding memory safety related security holes alone is huge.

The selling point of Haskell is that it's a Functional Programming first language (see: "Why Functional Programming Matters"), has a better statically type system than C/C++/Java which makes whole classes of bugs common in those languages harder to write in Haskell (so if writing correct code is a priority, that's your use case), and memory safety related security holes are harder to write, just like with Rust. Laziness (or non-strictness, whatever) is also a big if controversial selling point (why: read "Why Functional Programming Matters").

If you like slightly less opinionated (or non-strict by default) languages, you could go with OCaml or Standard ML instead.

Why would you prefer Rust? Why don't you ask a Rust advocate?


Rust has better tooling, more direct control in performance-sensitive contexts (no opaque performance traps like, arguably, Haskell), and more community/industry support (meaning more useful and high quality packages). So from the perspective of practically solving problems, it seems better to me. But I could be convinced otherwise by a good argument.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: