News for hackers. Stuff that matters.
Re:Multicore OCaml: Feb 2020 update by kccqzy on Friday February 28, 2020 @03:09PM (#22445885)
I didn't downvote you, but you are mistaken.

I don't know about Go GC but your comment about Haskell is very off.

> Not sure how Haskell's GC works, but I'm guessing it more or less depends on Haskell's immutability guarantees.

This is false. Just because you see immutability on the surface doesn't mean the GC still sees a lot of immutability.

Several reasons. The first is that even pure code can depend on interior mutability in a safe way using the ST monad, or in an unsafe way using the IO monad. (The GC can't just say, I give up when a user uses an unsafe function.) You might think that interior mutability is rarely used, but that'd still be wrong. Even something as commonplace as a hash map (from unordered-containers) uses interior mutability under the hood. Just read the source code and you'll see it. Here: http://hackage.haskell.org/package/unordered-containers-0.2.... Just grep for runST.

The bigger problem is laziness. How is laziness implemented? A value is represented as an unevaluated thunk, a closure to compute the value. When the value is needed, the closure is run and then replaced by the resulting data. This is mutability. And this is something that almost every Haskell program relies on.

I've explained this many times on HN. See eg https://news.ycombinator.com/item?id=21674749

Re:Multicore OCaml: Feb 2020 update by __s on Friday February 28, 2020 @03:51PM (#22446248)
It isn't entirely false. Haskell's GC can take some shortcuts when dealing with immutable objects as they can't reference objects older than themselves, including referencing themselves
Re:Multicore OCaml: Feb 2020 update by kccqzy on Friday February 28, 2020 @08:14PM (#22447937)
If objects can't reference themselves, do you think recursion is impossible in Haskell?

    powersOf2 = 0 : scanl (+) 1 (tail powersOf2)

    fibonacci = 0 : scanl (+) 1 fibonacci
As I have already explained, immutable objects in Haskell often use laziness. And laziness requires mutability.
Re:Multicore OCaml: Feb 2020 update by hope-striker on Friday February 28, 2020 @05:29PM (#22447009)
Really? I have no experience with Haskell's internals, but self-referential objects are fairly common in Haskell thanks to its non-strictness. The simplest one is probably the list with one element repeated forever.

    ones = 1:ones
Re:Multicore OCaml: Feb 2020 update by __s on Saturday February 29, 2020 @10:26AM (#22450990)
I'm an idiot. I meant that objects can't reference objects newer than themselves
Re:Multicore OCaml: Feb 2020 update by hope-striker on Saturday February 29, 2020 @09:12AM (#22450627)
> The bigger problem is laziness. How is laziness implemented? A value is represented as an unevaluated thunk, a closure to compute the value. When the value is needed, the closure is run and then replaced by the resulting data. This is mutability. And this is something that almost every Haskell program relies on.

Tangent: does GHC ever decide that it's cheaper to just potentially evaluate something twice than to use thunks?

Re:Multicore OCaml: Feb 2020 update by throwaway894345 on Friday February 28, 2020 @04:05PM (#22446353)
Ah, thanks for correcting me. Like I said, I am unfamiliar.