Live data from Hacker News

Why Not Haskell?

neugierig.org

81–90 of 134 posts

Re: Why Not Haskell?

#81
Haskell is the first language I was ever fluent in. These days I mostly work in python and erlang with a smattering of ocaml but learning haskell had a huge influence on the way I think about software.

I find it hard to articulate the ideas that I came away with. Something like 'code should be built out of small, composable abstractions that obey simple algebraic laws'. It's incredible how powerful this is in combination with pure code (which enables easier composition and algebraic reasoning), typeclasses (which make it easy to express the interface to an abstraction) and quickcheck/smallcheck (which make it easy to express and test the laws which the abstraction should obey).

Others have written about this more clearly than I ever could. In particular, Conol Elliot's writing on denotational semantics [1] and Chris Okasaki's Purely Functional Datastructures [2].

The haskell community tends to be dominated by academic research so it's easy to dismiss the typical examples as impractical. Right now I'm trying to apply the same ideas to Kademlia routing in erl-telehash [3]. Hopefully I will eventually be able to demonstrate what I struggle to articulate.

[1] http://conal.net/papers/type-class-morphisms/

[2] http://books.google.com/books/about/Purely_functional_data_s...

[3] http://github.com/jamii/erl-telehash

Re: Why Not Haskell?

#82
First, the title annoys me: "Why not X?" is almost always the wrong question to ask, because it implies that X is so great that don't even need a reason to use it. If you want me on board, the relevant question is "Why X?".

Second, A resulting correct Haskell program is likely more reliable, maintainable, and perhaps faster seems fallacious to me. It might as well be that because Haskell is hard, only people with a deep understanding and appreciation of computer science ever venture into it. So, in other words, Haskell programs are good because they're written by very bright people thinking very hard about what they are doing. The same reason old mainframe code works well and average PHP doesn't.

Re: Why Not Haskell?

#83
post #9

If the question is, should we use Haskell to solve this problem, or should we use JavaScript, I can't imagine that the answer is often Haskell. (Maybe if the question is, should we use OCaml or should we use Haskell...) That said, what really came out of left field was the OP saying that he and his friends are more and more using Go. Is Go adoption happening? I'd love to have a systems programming language that isn't…

What I want to know is, is Go still undergoing major revisions? I don't seem to have been able to find an answer to this, and it's annoying. I remember there being some fairly big changes some time ago -- not so recently now, but after it was already public -- and I want to know whether that's going to still be happening before I bother learning it.

There have been many changes to both the Go language and the stdlib, but it is really easy to keep your code updated (specially since gofix was introduced: http://blog.golang.org/2011/04/introducing-gofix.html ) so this should not be an obstacle to learning the language.

That said, version "1" of the language is due for early next year, which should provide a long-term stable language and set of libraries, for details see:

http://blog.golang.org/2011/10/preview-of-go-version-1.html

Re: Why Not Haskell?

#84
post #12

Haskell is a hard language because (a) laziness is not intuitive, especially when space-performance matters (sadly, it does) and (b) pure functional programming is just not practical for most people. Like the OP said, it's awesome for brain-stretching, but not the easiest language to use. I started writing a game in Haskell and found that the scaffolding necessary to do randomness in the "right" way was just too pain…

> I started writing a game in Haskell and found that the scaffolding necessary to do randomness in the "right" way was just too painful. It could be that I hadn't learned the idioms well-enough to see a better way of doing things; but if I had trouble, I think it's fair to say that most people would. This. My current opinion as to what would constitute a perfect language is: something built on top of Haskell which wo…

> My current opinion as to what would constitute a perfect language is: something built on top of Haskell which would, in some as-yet-unconceived-of way, make it easy to thread mutable state exactly where it needed to go in your code.

What's the difference between that and an imperative language?

Re: Why Not Haskell?

#85

First, the title annoys me: "Why not X?" is almost always the wrong question to ask, because it implies that X is so great that don't even need a reason to use it. If you want me on board, the relevant question is "Why X?". Second, A resulting correct Haskell program is likely more reliable, maintainable, and perhaps faster seems fallacious to me. It might as well be that because Haskell is hard, only people with a d…

I am guessing that you have never worked with Haskell?

Your hypothesis -- that difficult languages result in more bug-free code, due to selection bias -- is, to say the least, somewhat of a minority opinion.

But even if we accept this, Haskell is different. The difficulties of Haskell are not arbitrary. Nor are they related to the difficulty of understanding the machine at a low level. In fact, Haskell insulates you from all that; it's easily the highest level language in common use.

It's that Haskell insists on program correctness. You have to consider the entire range of values that any function could ever process. And due to its purity, Haskell applies a razor to your thought process, cutting out all unjustified or implicit assumptions.

Luckily it also gives you tools of unparalleled flexibility when it comes to creating abstractions. Creating a new abstraction (like the composition of two functions) isn't just as easy as function application, that's how you do function application in Haskell. Typically with less syntactical fuss than it takes Java to initialize a variable.

Re: Why Not Haskell?

#86
Haskell demonstrates the difference between theory and practice.

What does it matter if an arbitrary language X is beautiful in theory if nobody uses it in practice because they don't comprehend it?

Consider all those theoretically beautiful languages: APL, Ada, Lisp, Haskell, OCaml, ... How many developers use them? I think less than 1 percent in summary. Why?

Because syntax really matters. For this reason imperative languages like C++, Java, Python, Perl, Javascript, even PHP are so successfull.

As a long experienced programmer I discovered that (at least for me) the best technique is not to be fixed on one language but to use metaprogramming. That means, use your current favorite language (or create your own DSL) and compile it to the platforms/languages of choice.

My current recommendation: shenlanguage.org

Re: Why Not Haskell?

#88
post #64

I've been doing a whole lot of scientific Python lately, and every time I let my program run for like an hour only to crash on an array of the wrong dimensions, or pass in a scalar where an array is expected or vice versa, I swear and wish I was using a strongly typed language like Haskell. If only it had the same tools as SciPy I'd be all over doing my scientific work in Haskell. (Not to mention it would have faster…

Sounds to me like you're doing it wrong. I write scientific Python code every single day for work and I (nor anyone else who works with me) never run in to those kinds of problems. Why are you running simulations that take an hour before you even know your code work? Where are your unit and integration tests? Every piece of our software stack has (or should have...) tests that verify all the bits fit together correct…

The point is that a whole class of things that you would have to write unit tests for, you get "for free" with strong typing, and for a lot of the others, there's QuickCheck. Or as the old saying goes, why get a dog and bark yourself?

Re: Why Not Haskell?

#89
post #87
post #80

Earlier quoted context omitted.

Nope. There is nothing that forces Googlers to either use or promote Go.

Well they ain't gonna use or promote C# are they?

If it's the best tool for the job, why not? They keep using and promoting Java despite Oracle suing their pants off over it.

Re: Why Not Haskell?

#90
post #87
post #80

Earlier quoted context omitted.

Nope. There is nothing that forces Googlers to either use or promote Go.

Well they ain't gonna use or promote C# are they?

Google is a very big and diverse organization, I'm sure there are some that do promote pretty much every language you ever heard of (and many you didn't).

Actually, I remember some years ago reading about some Googlers that used C#, no clue what for, and it was a while ago, but it is not unrealistic.

Post reply on HN