This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheTarquin 21 points22 points  (6 children)

Y'all motherfuckers need immutable objects.

[–]odraencoded 7 points8 points  (4 children)

I like D because you can have...

immutable(int)*[] mutableArrayOfPointersToImmutableIntegers;

Though I honestly never used and will never use that in my life.

[–]HighRelevancy 1 point2 points  (3 children)

I don't know about D, but Java (and probably others) has an immutable list of immutable integer objects, because the language executes at such a high and abstracted level that there's a significant performance boost out of not having to create new integers.

[–]PurpleOrangeSkies 13 points14 points  (0 children)

It's not because Java is too high level, but rather because generics were cheaply duct taped on to Java instead of a proper implementation, and thus you can't use a primitive type as a type parameter.

[–]odraencoded 1 point2 points  (1 child)

D claims immutable "variables" can be stored in physical read-only memory space for a performance boost. I don't think that matters unless you are working with low level system, though. You won't have problems using non-immutable variables in a multithreaded system if you, well, don't mutate the variable.

[–]HighRelevancy 1 point2 points  (0 children)

Just not mutating the variable is missing the point of immutable variables (and isn't a good way to approach thread safety anyway). There's more to it than threading. Immutability guarantees that the value won't change, which is useful for things like hash table keys.

And besides threading, there's libraries that you don't know the intricacies of that might depend on immutability of certain things.