1

Haskell's MArray is supposed to provide a mutable array.

I wonder how does it compare with a normal mutable array in an imperative programming language like Java or C. Is there any performance benchmark or feature comparison?

Mahdi
  • 1,871
  • 2
  • 24
  • 41
  • 2
    I'm voting to close this question as off-topic because there's no clear answer to general questions about performance. See e.g. https://ericlippert.com/2012/12/17/performance-rant for reasoning. – Mark Seemann Jun 16 '17 at 06:09
  • 2
    Thanks @MarkSeemann but I don't think it's off topics. I am asking about the difference between two paradigms in implementing a data structure in terms of speed. And as I am not a Haskell developer, I could not write a good comparison code myself. Regarding performance being a bottleneck, I think this does not apply to my question as it is not related to a specific piece of software. It has been asked to make decisions regarding the design of a programming language. Because of the same reason, the difference is relevant in my case. – Mahdi Jun 16 '17 at 07:56
  • 1
    I don't think this is a general question about performance. It's hard to understand how Haskell's array types are implemented (boxed vs unboxed types, how they relate to native arrays and so on), so good answers about this are useful. For example, if you look at the code for the unboxed [`STUArray`](http://hackage.haskell.org/package/array-0.5.1.1/docs/src/Data.Array.Base.html#STUArray) you will see that it uses a [`MutableByteArray#`](https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Data-Primitive-ByteArray.html#t:MutableByteArray-35-). But that doesn't really tell you much. – Shaun the Sheep Jun 16 '17 at 10:17
  • 1
    See https://stackoverflow.com/questions/5773070/how-are-mutable-arrays-implemented-in-haskell for a discussion about how MArray (a.k.a. IOUArray/STArray/STUArray) is implemented, with a link to the relevant paper. – hao Jun 20 '17 at 15:17

0 Answers0