Hacker News new | ask | show | jobs
by redo2 5545 days ago
What is the point of ML now that we have Haskell? This is not meant to be a troll; I'm seriously asking. Haskell proponents mention ML and Miranda only in passing and as lesser (in terms of purity and ease of use) antecedents of Haskell. What reasons are there to still use it?
5 comments

Just because Haskell is purer that doesn't mean ML is pointless. Under the right circumstances even a functional program can benefit from mutable state. One example (perhaps the only real example; I don't know) can be found in the SML New Jersey implemetation of splay trees, which modifies the tree during certain operations.

Even without the purity question there are other things to consider. ML is evaluated strictly, for example. I don't know much Haskell but I don't believe it has any direct counterpart to ML's functors, either. There are probably many other differences. Haskell is definitely more popular and is still a niche language, so the reason you don't hear much about ML's benefits is probably just because it has so few users.

Thanks.
Robert Harper has recently started blogging and is claiming a big success with teaching functional programming to first year students. http://existentialtype.wordpress.com/2011/03/21/the-dog-that...

"...we are placing a strong emphasis on verification and proof as tools for the practicing programmer, chief among these being the infamous hellhounds of Computer Science, induction and recursion."

andrejbauer wants to know why Prof Harper is using SML instead of Haskell. There is a slight technical difficulty about proofs in a lazy language but "Well, in Haskell you’d have to use coinduction rather than induction, since the recursive definitions of datatypes are understood as final coalgebras."

That seems to make the point that ML is easier due to synergies with learning to create inductive proofs in maths lessons.

While I think Haskell is a superior language is most respects and I would definitely prefer it for my personal use, I think SML is probably a better language for teaching, particularly for a language-theory course.

Two are two particular issues: laziness and the type system. Laziness is both complicated in practice and makes reasoning about the evaluation semantics more challenging. It can also lead to unexpected behavior for those unaccustomed to it (which will be nearly everybody). Furthermore, the type system is much more complex which makes it a bad model for learning about implicit typing and type inference.

Because of the purity and laziness in Haskell, it is difficult to reason about the performance of what you're writing in Haskell. Fundamentally, a computer is not functional - it does everything via side effect - and I think Haskell goes too far in abstracting this away.
Let me first say that Haskell is extremely cool and every developer should experiment with it. Laziness supports beautiful/declarative expression of programs, and there are some useful ways of structuring programs (e.g., operating over lazy lists) that are far more natural in Haskell than OCaml.

However, for some programs, having a type-system that is fussy about side-effects imposes a significant effort burden for a meager correctness payoff. (For other programs, this bean counting is a huge win.) Also, I find it tricky to reason about the performance of lazy programs.

OCaml (and presumably SML) hit a practical sweet-spot in the statically-typed functional programming world.