Ask HN: Do you know any computer language where collections are unified?

https://news.ycombinator.com/item?id=29685302
by scotty79 • 5 years ago
6 18 5 years ago

In most languages creating array, list, set, mapping, usually requires different code to create them and to access them.

Do you know any language where you create generic collection and just specify what you require of it?

For example, you might specify that you require collection to be indexed with numbers, and have quick access to elements by their index. Or have ability to add element at the end quickly or have the ability to find next element quickly. Or have elements with quick parent access, or quick children access, or quick arbitrary inserts or you want collection to be indexed multidimensionally.

Language itself would pick the right algorithms for your collection for example picking fixed length immutable array (for the purposes of iteration), but also set (for quickly checking presence of element).

Creation, access and writing should be kept as similar as possible with different algorithms.

This system should of course be extensible. So that you could implement fast access to elements by creating and updating various task specific indexes into your data and have them available though built in language syntax.

The only thing that comes to my mind that somewhat attempted this is C++ template library, which offers various collections and iterators while trying to keep the interface mostly algorithm agnostic.

Related Stories

Loading related stories...

Source preview

news.ycombinator.com