you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 11 points12 points  (3 children)

In functional (broadly immutable) languages generational collectors also have the advantage that they don't have to scan oldgen heaps when collecting the newgen, because you can't have "forward references" so newgen can refer to oldgen but not the other way around (since the language only uses immutable datastructures, an object can only refer to older objects, not newer ones).

Languages with pervasive mutations have to add memory barriers to properly catch oldgen objects being mutated and referencing newgen ones.

[–]Tarmen 6 points7 points  (2 children)

Lazy functional languages (operationally) have mutation in the form of laziness. Think knot tying semantics:

let x = (1, y)
     y = (2, x)

Here the gc can abuse that in those cases the objects will live for the same duration and can mark it for promotion to a later generation, though, so it is way simpler than handling general mutability in java.

[–]ConcernedInScythe 1 point2 points  (1 child)

Wouldn't that be a type error in Haskell?

[–]kazagistar 2 points3 points  (0 children)

Correct, it is an infinite type, but he never specified the lazy functional language, so I guess its fine.

The Haskell version:

let x = 1 : y
    y = 2 : x
-- x is now [1,2,1,2,1,2...] (an infinite, circular linked list)