> You might think that it is unfair to compare multithreaded Haskell against C++ that is not multithreaded. And you’re absolutely right! But let’s be honest, manually working with pthreads in C++ is quite the headache, but parallism in Haskell is super easy.
C++ has std::thread and it would be very simple to parallelize this program, so yes it is unfair. I also wonder just how optimized the C++ AVL library is when it contains "//Assignment 6" at the top of its header. The C++ program is also non-optimal in that it is doing 2x lookups for each insert, once for the insert and then another to increment the counter. I haven't investigated the Haskell to see if it does the same.
Another important point is that mutable single node data structures like AVL or red black trees provide a property that the Haskell data structure cannot: stable iterators. If you don't need this property then you can usually get better run-times by using a more cache efficient data-structure like a BTree.
C++ has std::thread and it would be very simple to parallelize this program, so yes it is unfair. I also wonder just how optimized the C++ AVL library is when it contains "//Assignment 6" at the top of its header. The C++ program is also non-optimal in that it is doing 2x lookups for each insert, once for the insert and then another to increment the counter. I haven't investigated the Haskell to see if it does the same.
Another important point is that mutable single node data structures like AVL or red black trees provide a property that the Haskell data structure cannot: stable iterators. If you don't need this property then you can usually get better run-times by using a more cache efficient data-structure like a BTree.
This is a very biased comparison.