Live data from Hacker News

Rust as a gateway drug to Haskell

xion.io

91–100 of 218 posts

Re: Rust as a gateway drug to Haskell

#91
Isn't the most significant line: "For work-related reasons, I had to recently get up to speed on programming in Haskell"?

I was somewhat disappointed not to have a followup to what work-related reasons there might be. Note also that the About page says "work at Facebook".

Re: Rust as a gateway drug to Haskell

#92

The article references using trait objects for dynamic dispatch. FWIW, I found them extremely limited: you can't use generics, can't return Self... I wonder how often people use them.

What do you mean you can't return self? I'm just starting out with learning rust, but from what I've gathered you can use objects in a myriad of ways that will allow you do what you need. Instead of returning self, you could just pass a reference - you need to mutate self then just pass a mutable reference. Did I miss something here?

Returning Self in a trait object isn't possible; it's not object safe. In order to return Self, you'd need to know the concrete type of the thing, and when you have a trait object, that's erased.

Returning a trait object instead of plain Self would work though.

Re: Rust as a gateway drug to Haskell

#93
post #70
post #60

Earlier quoted context omitted.

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

Most large codebases are terrible, and these facts are not unrelated.

Re: Rust as a gateway drug to Haskell

#94

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…

> rarely producing production grade systems.

https://www.rust-lang.org/en-US/friends.html has been growing at a pretty hefty pace lately!

Re: Rust as a gateway drug to Haskell

#95
post #86

Earlier quoted context omitted.

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…

It is also possible to avoid GC pauses causing problems in your application with a load balancer. Basically shifting load between haskell processes when a big GC is imminent. Read about that technique from Simon Marlow of Facebook's Haskell team. Of course it would be awesome to not have to worry about that.

Nice -- this technique never came up when I searched /r/haskell for GC pause workarounds. And yes -- it would be awesome not to have to worry about this.

Re: Rust as a gateway drug to Haskell

#96
post #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.

Haskell can be made very fast. The problem is that at least for me, performance is often quite non-intuitive. As in, make tiny change to program, it is now a hundred times slower. Then you get to hunt down the reason why it's now doing too much work/ why stream fusion isn't working anymore/why it's leaking so much space/etc for hours.

I enjoy writing Haskell for small hobby projects, but I doubt I would choose it for real work now that F# and Rust exist.

Re: Rust as a gateway drug to Haskell

#97
post #28
post #22

Haskell/GHC will soon have an extension for linear types, which will bring the languages much closer: http://blog.tweag.io/posts/2017-03-13-linear-types.html

Yeah right. If only the standard library (the base package) could immediately be converted to use linear types and we can all benefit from that! (Hint: it won't. Even the fairly no-brainer AMP and BBP took an absurdly long time. This is extremely slow by Rust standards. The Haskell community might, but the stewards of the standard libraries don't have the move-fast-and-break-things attitude.)

> Even the fairly no-brainer AMP and BBP took an absurdly long time

This is because, believe it or not, Haskell is actually used in the real world and people care about their code not becoming broken.

Re: Rust as a gateway drug to Haskell

#98

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.

You might want to consider F# as well. It supports both lazy and greedy functional programming very nicely.

Re: Rust as a gateway drug to Haskell

#99

Earlier quoted context omitted.

Swift works reasonably well on Linux. You can even run Swift on Windows 10 through Windows Subsystem for Linux.

I tried under Arch a few months ago and found swathes of the standard library didn't appear to work, is this something which has been fixed?

AFAIK only the core language is fully ported, for the libraries ... it is a work in progress.

Re: Rust as a gateway drug to Haskell

#100
post #8

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.

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 :)

Why not SML/CML where you basically get haskell syntax and types, but get modules, no laziness, and you can mutate things when it's more efficient to do so.
Post reply on HN