3 ms·
Well, Haskell (say) can never be as fast as C++, because of immutability. That means that it has to make a new place to store the new value, which means an all
by AnimalMuppet 6y ago
Well, Haskell (say) can never be as fast as C++, because of immutability. That means that it has to make a new place to store the new value, which means an allocation. That's not dependent on implementation.
(Except, I suppose, you theoretically could implement C++ so that it also allocated every variable. Still, I think the point is valid: Haskell, by its nature, has to do things that C++ doesn't, so Haskell is going to have a very hard time being as fast as C++.)
- pas 6y agoImmutability doesn't mean no one can implement a Haskell extension that allows safely describing and composing operations that use mutability on the inside. Of course on current hardware with current compiler Haskell programs tend to be slower, and also tend to be more correct compared to C/C++ (maybe even compared to let's say C++20).