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.

funkia/list compatibility?

See original GitHub issue
  1. Could ts-belt be used with https://github.com/funkia/list ?

List is a purely functional alternative to arrays. … List is immutable. … Since List doesn’t allow mutations it can be heavily optimized for pure operations.

  1. List’s benchmarks are quite impressive. Would like to see a comparison with ts-belt for the operations they share, like map. Or compare ts-belt with Ramda + List, since List was designed to seamlessly integrate with Ramda.

  2. Maybe ts-belt could even benefit from integrating List?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
paldepindcommented, Dec 29, 2021

Hi @redbar0n. Thanks for the question. From what I can see above the benchmarks only test map, filter, and reduce. These operations are not the most interesting to benchmark as they all are going to have O(n) complexity and for such operations arrays and cons-lists/singly-linked lists are going to be the fastest due to lower constants.

Compared to arrays you get performance benefits with operations where it’s possible to achieve an improvement in complexity due to the efficient immutable data structure that List implements. For instance prepend, append, concat, splitAt, insertAt, take, etc. are going to be much faster for large sizes than arrays.

You can see this, for instance, in the insert benchmark. Ramda is slightly faster for small arrays but quickly becomes much slower than List. This is because inserting an element in an array requires copying the entire array. So inserting one element in a 1000 element long array causes all the 1000 elements to be copied into a new array. List on the other hand uses structural sharing to avoid most copying and will have to copy only log_32(1000) ≈ 2 elements.

2reactions
mobilycommented, Jan 15, 2022

thanks for the detailed explanation @paldepind 🚀 to sum up:

  • ts-belt is compatible with funkia/list
  • use funkia/list if you want to achieve high performance when dealing with really large lists, for instance: adding at the head, getting the tail, splitting will be faster, but if you need to randomly access an item funkia/list will be slower
Read more comments on GitHub >

github_iconTop Results From Across the Web

funkia/list: An immutable list with unmatched ... - GitHub
Both variants are 100% TypeScript compatible. Does one thing well. Instead of offering a wealth of data structures List has a tight focus...
Read more >
@funkia/list - npm
Written in TypeScript and comes with accurate types that cover the entire library. Fantasy Land support. Ships with tree-shaking compatible ES ...
Read more >
list - UNPKG
12, <a href="https://codecov.io/gh/funkia/list"><img ... Both variants are 100% TypeScript compatible. ... 55, * **Fully compatible with tree-shaking**.
Read more >
Compatibility (mechanics) - Wikipedia
Compatibility conditions are mathematical conditions that determine whether a particular deformation will leave a body in a compatible state. In the context of ......
Read more >
Arden on Twitter: "This looks extremely useful https://t.co ...
... support - TypeScript types - Ramda integration - Fantasy Land compatibility. Feedback is much appreciated See it here: https://github.com/funkia/list.
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