Hacker News new | past | comments | ask | show | jobs | submit login
A Comparison of Functional Data Structures on the JVM (github.com/lacuna)
122 points by prospero on Oct 8, 2018 | hide | past | favorite | 17 comments



For those interested in this type of thing, Li Haoyi created an in depth look at the Scala structures.

http://www.lihaoyi.com/post/BenchmarkingScalaCollections.htm...

It includes some interesting commentary as well.


Note that Scala 2.13 (next release) includes a CHAMP hash map implementation, first contributed by the original author and then refined by several Scala contributors, most notably Jason Zaugg (@retronym) and Josh (@joshlemer)


I tried to include these, but it wasn’t immediately obvious how to construct them from outside Scala without CanBuildFrom. If anyone wants to open a PR or even provide a few hints, I’d be happy to update the benchmarks.


Scala 2.13 greatly simplifies the external interface of the collections and no longer requires CanBuildFrom [1]. You may find them much easier to work with now.

[1] https://scala-lang.org/files/archive/api/2.13.0-M5/



Thanks for sharing! One quick question: in the methodology section, you mention that the results are from a median value out of repeated runs. While I get that you run JITted code, you also mention that it makes the runs isolated from GC side-effects.

Just out of curiosity, what did you do to ensure that GC would not interfere with the execution while the tests are running?


By forcing the GC to run in between tests, basically. The README for the benchmarking tool describes it in more detail: https://github.com/hugoduncan/criterium.


Pet peeve: I wish people would call them persistent or fork-on-write, but functional at least is better than immutable.


Would "purely functional data structures" float your boat?

I suspect the idea is to tie in with the idea of '(purely) functional programming', which is where these will shine.

In any case the term '(purely) functional data structures' seems pretty well entrenched and dates at least to Okasaki's thesis in the late 1990s, possibly earlier (I'm not an expert). In fact, it looks like the link actually mentions Okasaki's work.


So an appeal to authority? [0] Or to tradition, I'm not sure.

[0] https://www.logicallyfallacious.com/tools/lp/Bo/LogicalFalla...


No, not really. I'm not saying anything about what these things ought to have been called in a perfect world (though I think it actually fits pretty well). I'm observing that they've been called by this name for a while, so even if you can find an unambiguously better one, popularizing it may be hard.


I always thought it came from the well-known 'Purely Functional Data Structures' by Chris Okasaki.


Why? Fork-on-write seems very descriptive and nice, persistent seems less illuminating than immutable. Functional... eh, as someone who already knows the functional programming paradigm, I know what it means, but it would otherwise be an unhelpful descriptor.


I see you have written interfaces like List & Maps. Probably, we need to use interfaces from Java native, but provide better implementation through bifurcan. This makes it easy for existing applications to switch to bifurcan where they need.


Indeed great work! Is Google's guava collections part of this research?


Guava’s “immutable” collections are effectively read-only indices, and do not support efficient updates.


Great work!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: