Live data from Hacker News

Rust as a gateway drug to Haskell

xion.io

211–218 of 218 posts

Re: Rust as a gateway drug to Haskell

#211
post #197
post #180

Earlier quoted context omitted.

>And if it's not just a change in a default option, but the removal of laziness, we lose something, which will make the choice less obvious. What would we exactly lose? >As far as I can see, Idris is too much like Haskell to take its place. Porting thousands of libraries to a new language is a huge effort, so a huge advantage is required, which I don't see Idris offering. That is true, though. Perhaps Rust is the saf…

> What would we exactly lose? We'd lose composability and clearer code. This[1] section of the Haskell Wiki contains a good example. In short, with something like this: any :: (a -> Bool) -> [a] -> Bool any f lst = or boolLst where boolLst = map f lst the compiler can produce reasonably optimal code, because it doesn't have to convert the entire [a] to a [Bool] , because of lazy evaluation -- when or encounters the f…

I don't know Idris so this syntax is probably wrong, but by reading the docs for a short while, this would be

any : (a -> Bool) -> Lazy List a -> Bool

... which would make it as performant and clearer than Haskell's any, since the laziness is explicit.

Someone with actual Idris experience might tell if it actually would work like this :) I guess we'd have to make sure that the used or function is also lazy.

Re: Rust as a gateway drug to Haskell

#212

Earlier quoted context omitted.

Tell that to IBM that uses Swift in production. See IBM's Kitura open source server framework if you are interested.

They use a language without a standard library in production?

I'm sure you can find yourself the answer if you are really interested, here is an example: http://www.computerworld.com/article/3122994/apple-mac/ibm-s...

Or this one https://developer.ibm.com/swift/

Re: Rust as a gateway drug to Haskell

#213
post #211
post #197

Earlier quoted context omitted.

> What would we exactly lose? We'd lose composability and clearer code. This[1] section of the Haskell Wiki contains a good example. In short, with something like this: any :: (a -> Bool) -> [a] -> Bool any f lst = or boolLst where boolLst = map f lst the compiler can produce reasonably optimal code, because it doesn't have to convert the entire [a] to a [Bool] , because of lazy evaluation -- when or encounters the f…

I don't know Idris so this syntax is probably wrong, but by reading the docs for a short while, this would be any : (a -> Bool) -> Lazy List a -> Bool ... which would make it as performant and clearer than Haskell's any, since the laziness is explicit. Someone with actual Idris experience might tell if it actually would work like this :) I guess we'd have to make sure that the used or function is also lazy.

I was commenting on what the effects would be from removing laziness. I'm not experienced enough in Haskell to know whether making strictness the default option would make sense, although I've seen a quote from Simon Peyton Jones saying he'd do that if he could start over.

Out of curiosity, would you know whether there exists sufficient strictness pragmas in Haskell to translate your example Idris (pseudo) code into Haskell? I often hear about performance/memory usage pitfalls with Haskell laziness, so it'd be really nice if Haskell were able to emulate Idris in this regards, by enabling enough LANGUAGE pragmas to require explicitly annotating types if laziness is desired.

Re: Rust as a gateway drug to Haskell

#214
post #199

Earlier quoted context omitted.

Really bad benchmark ? Inappropriate choice of benchmark?

I have a hard time seeing the value in a Mandelbrot benchmark. I absolutely don't have a problem with benchmarks that make Haskell look bad (e.g. directory traversal, regex), but I would like a benchmark that provides insight into the code you'd feasibly be writing in that language.

Isn't Haskell intended to be a general purpose programming language?

Re: Rust as a gateway drug to Haskell

#215
post #43

Earlier quoted context omitted.

> .. you can write vastly more complicated programs that are, say, 80% as fast as hand-optimized C for only 10% of the effort of hand-optimized C. I don't mean to be personal, but your quantative claim smells a little like unsubstantiated BS. Do you have any data to back it up? > That said, Haskell performs pretty well in the toy benchmarks anyway. Currently, "pretty well" looks like GHC performance is 50% to 10% of…

The make errors are a bit weird because the programs build on my machine no problem. In parts haskells slowness seems to be because no one cares enough to work on it. Can't say for sure, though, so maybe I just should try a task and implement it to see how fast it'd be without amazing optimization foo. Although of course these benchmarks aren't really representative of the real world because they'd just end up as a c…

>> The make errors are a bit weird because the programs build on my machine no problem. My fault (except for pi-digits and regex-redux).

I neglected to work-through the force-reinstalls that inevitably follow my update of the GHC compiler.

Done.

Re: Rust as a gateway drug to Haskell

#216
post #206

Earlier quoted context omitted.

I agree with all that, particularly the bit about the c ffi call. It's more relevant to compare Rust with C and C++, as Rust is a language that could reasonably display C for the ffi call. But then remember that @wyager is claiming >80% as fast as hand-optimized C for only 10% of the effort of hand-optimized C If it's really only 10% of the effort then one shouldn't really have "to work on it" to get semi-decent perf…

Tried my hand at the knucleotide[1] one. Lifted the algorithm from the fastest rust solution. As optimization I dropped some Unpack pragmas and strictness annotations, used Data.Hashtable.Cuckoo for in-place updating hash tables because that seemed necessary for the task, and added naive parallelization via let outputs = map (exec content) tasks `using` parList rseq That got around 24 seconds which seems acceptable f…

http://benchmarksgame.alioth.debian.org/play.html

Re: Rust as a gateway drug to Haskell

#217
post #145
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.

OCaml seems like the ideal language for me on the surface, but the onboarding process is... suboptimal IMO. There's a lack of good soft/hard documentation (AKA the "no, type signatures are not sufficient documentation" problem), but my biggest turn off is the multiple standard libraries. Some might see that as a plus, but when I'm just trying to get a small learning project off the ground, and I find out there's a cr…

I feel like the biggest thing missing from OCaml is a Cargo-like build tool (probably using OPAM under the hood for dependency management). It would also be nice if OPAM had better cross platform support. The only way I could get it working on Windows was through one of the distributions that bundled Cygwin.

Re: Rust as a gateway drug to Haskell

#218
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.

F# does have operator overloading.

But it's missing the module system, which is IMHO OCaml's best feature.
Post reply on HN