question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After reading the other discussions about API design and backing implementation I decided to put some more work in to the tinkering I’ve been doing on persistent data structures. I think I now have enough done to start a discussion about the best approach.

https://github.com/amaranth/persistent-collections

There are interfaces for immutable collections, lists, sets, maps, sorted sets, and sorted maps. The implementation for lists is a bit-partitioned vector trie with O(log32n) scaling. The hash map is sort of halfway between the standard clojure style HAMT and the CHAMP design, I use separate arrays for child nodes and data. The tree map is using an AA tree, which apparently Scala uses as well. The hash set and tree set are just wrappers around the map implementations. There is also a (most likely broken) finger tree implementation which I plan to try to use for a priority queue and possibly ordered sets and maps.

The performance of the library is… okay. I’m sure more optimization work can be done but my main goal was to get something that works first. On that note the unit tests could certainly use some work, right now they’re mostly just ported from @andrewoma’s dexx library (and I’ve just noticed the license gradle plugin wiped his name from the copyright headers, oops) but they at least show things aren’t completely broken.

I’d love to see an API like this adopted, even if we decide to use UncleJim or dexx or pcollections for the backing implementation. The key design aspect mirrors the approach UncleJim uses in that the way to do mass updates to one of the collections in a performant way is to transform a Sequence and then turn that in to a new collection. This lets us avoid exposing the transient versions to the API which should remove any chance to misuse them and accidentally lose immutability.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SolomonSun2010commented, May 28, 2017

I really expect lazy streams API add these powerful and convenient methods : repeat/cycle, repeatedly/generate, iterate, unfold, resource, reject, like in Elixir and Clojure: https://hexdocs.pm/elixir/Stream.html#unfold/2

0reactions
SolomonSun2010commented, May 29, 2017

@ilya-g Thanks, if provided by stdlib will be more convenient to every average programmer. I think, one of the programming trend is the Lazy Sequences . Is there the equivalence like Transducers in Clojure ? https://github.com/matthiasn/talk-transcripts/tree/master/Hickey_Rich

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best API List Alternatives - 2022 - Product Hunt
We've listed the top 19 alternatives to API List. The best API List alternatives are: Public APIs, PhantomBuster, sznm apps, Dash, ReadMe Build....
Read more >
Crypto API - Documentation - Alternative.me
Description: Overview of all available crypto currencies, use the returned id to retrieve more data on a specific crypto currency on the ticker...
Read more >
7 Best Google Maps API Alternative to Know in 2022
Can't find a good Google Maps API alternative? No worries, we'll help. We compiled a list of the best alternatives to Google Maps...
Read more >
Not All Microservices Need to Be REST — 3 Alternatives to the ...
REST is not the answer to every API question ... While older than REST, SOAP is still a very valid alternative, so don't...
Read more >
10 Best Google News API Alternatives For 2022 - apilayer Blog
What Are The 10 Best Google News API Alternatives For 2022? · Zenserp · Guardian API · Bloomberg API · Bing News API...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found