Live data from Hacker News

Rust as a gateway drug to Haskell

xion.io

61–70 of 218 posts

Re: Rust as a gateway drug to Haskell

#61
post #47

Earlier quoted context omitted.

Some people also complain about a tiny set of syntactic issues. Other than that I like both ml and ocaml.

Having learned ML languages via Caml Light, I never understood what those complaints are about. Maybe the only thing I would complain would be the separation between integer and floating point math.

not even the monomorphism, I forgot but there's a few warts at the syntactic level only.

Re: Rust as a gateway drug to Haskell

#63
post #47

Earlier quoted context omitted.

Having learned ML languages via Caml Light, I never understood what those complaints are about. Maybe the only thing I would complain would be the separation between integer and floating point math.

not even the monomorphism, I forgot but there's a few warts at the syntactic level only.

A few months ago I read monomorphism is the way to go performance wise.

Something about people writing fast code with Flow/TypeScript than with plain JavaScript because the typing leads to less polymorphic code which is easier to optimize for the compiler.

Re: Rust as a gateway drug to Haskell

#64
post #18

Earlier quoted context omitted.

ocaml is a great language in its own right too; the only haskell features I find myself really missing are do notation and operator overloading.

Some people also complain about a tiny set of syntactic issues. Other than that I like both ml and ocaml.

But that's what most devs do, right? If it doesn't look like C it's ugly, haha.

Anyway, Reason seems to have a bit nicer syntax than OCaml, I think.

Re: Rust as a gateway drug to Haskell

#65

Something that I found about going from Haskell to Rust was that Rust provides many powerful abstractions without compromising on performance. It was very frustrating to try reasoning about performance in Haskell due to its laziness. Every language has quirks about how to write performant code, but Haskell is notorious in my mind for being quite easy to write obscenely slow code in.

Wasn't the selling point of laziness performance?

"It only does what is needed!"

I didn't use Haskell but Nix and at least there it seemed reasonable to "not do" everything.

Re: Rust as a gateway drug to Haskell

#66

The similarities are striking. Both have a problem with undocumented or experimental modules for everyday tasks, both use compiler plugins to make sure that every package is using its own superset of the language (although in Rust this only applies to nightly), both tout lofty goals while rarely producing production grade systems. Rust is the first toe dip into the world of blog posts heralding the"coming of the age…

I think this is a little unfair on Rust. You can get a lot done using stable Rust.

Re: Rust as a gateway drug to Haskell

#67

Something that I found about going from Haskell to Rust was that Rust provides many powerful abstractions without compromising on performance. It was very frustrating to try reasoning about performance in Haskell due to its laziness. Every language has quirks about how to write performant code, but Haskell is notorious in my mind for being quite easy to write obscenely slow code in.

Haskell's laziness is an issue for you? Then how do strictness annotations (and/or module flags) not solve this problem?

Haskell also has inline-C FFI support for "type safe" performance escape hatches (in the sense that you can manually bring C constructs into Haskell's type system): https://github.com/fpco/inline-c

The only way that Haskell inescapably suffers from performance hits (that I'm aware of) is not in its laziness or lack of imperative programming support, but in its periodic GC pauses. In such cases where GC pauses are an issue, I still think you can -- in principle -- write more and more performance critical pieces of your application in a non-GC language (in fact, you could do this in Rust just as well as C/C++). You can also manually trigger a GC pass, although you cannot -- to my knowledge -- manually stop and start GC passes in your code.

This is the approach I'm currently taking in a performance critical VR application where GC pauses could absolutely be an issue (using as much Haskell as possible, with C and GC triggers as an escape hatch). And if someone could point out a flaw in my reasoning (in particular, how GC pauses might be inevitably avoided even with C FFI), I would gladly pay them money, because it's so important I not get this one wrong :).

Re: Rust as a gateway drug to Haskell

#68

Earlier quoted context omitted.

This is what's really nice about Nim. It writes like Python, but is fast like Rust. Ran across Option in it the other day, though it's not used heavily. I really wish there was something like Haskell but with a runtime like Nim or Go. Perhaps that is OCaml?

Have you looked at Swift? It's pretty similar to Rust, but eschews all the lifetime stuff in favour of a runtime that does reference counting.

Swift is useful if you're an Apple developer only targeting Apple users, seems like a bit of a niche.

Re: Rust as a gateway drug to Haskell

#69
post #14
post #8

Earlier quoted context omitted.

Comparing it against Rust doesn't really seem fair. If I wasn't using Haskell, I'd be writing Erlang, and last I checked GHC is much faster than Erlang/OTP. Certainly faster than CPython, Ruby, and most Node.js. Trying to compete with Rust or C++ performance in Haskell is certainly frustrating to reason about :)

While "GHC is faster than CPython" is a fairly accurate generalization, I still think python performance is easier to reason about. Haskell can give you fast code, but sometimes it will be super slow for no obvious reason.

super slow for no obvious reason

Obviousness is hard to pin down. What may be completely obscure to a Haskell beginner is obvious to a veteran. Is it really fair to count people's strict-language preconceptions against Haskell? I don't know.

GHC provides a wealth of profiling tools that an expert Haskell user can employ to find space leaks. Heck, experts generally know where to look (excessive use of lists, spine-nonstrict data structures) so that the profiling tools become a last resort.

Re: Rust as a gateway drug to Haskell

#70
post #60

Rust and Kotlin destroy any previous claims about practical usages of Haskell.

Languages without HKT are horribly impractical for large codebases.

Yet there are not many large codebases in languages with HKT, and even those which are there (mainly big Scala projects) do not use HKT
Post reply on HN