
I was wittering on about stream fusion and how great it is, and I got a message from Mr C++. (Mr C++ develops commercial games, and is obsessed with performance. For him, the only way to achieve the best performance is to have total control over every minute detail of the implementation. He sees Haskell is a stupid language that can never be fast. It seems he's not alone...) He said two things. The first was "it really perplexes me that Haskell insists that everything must be read-only". Naturally, I have a good answer to that one. (It's like being "perplexed" that relational databases refuse to keep table data in the same order. It's not to be awkward, it is a fundamental and important properly of the underlying theoretical foundation - the relational algebra, et al.) He also said what basically boils down to "being able to swap elements around in O(1) time and O(0) space is the whole thing that makes linked lists useful in the first place; take that away and it's rather pointless". I don't really have an answer to that one. (Lazyness and GC is probably going to kill most of the space cost. There's still a time cost - particularly the extra GC time...) I've asked this before and nobody answered, so I take it that nobody knows the answer... Does GHC *ever* do an in-place update on anything? Does the STG even have a command for that? I always assumed that the compiler tried to find instances where a new structure is created and the old one is no longer referenced, and make that be in-place. But now I'm not so sure...