Lispers like a-list so much because they are simple to implement and use. A-list means association-list. It works like singly linked list.
In my experiences, small size a-list is good enough if you want to keep things simple and straightforward. However, as the size of the data grows, a-lists can become inefficient due to their linear search time. Hashtables, on the other hand, provide average constant time complexity for lookups, insertions, and deletions, making them more suitable for larger datasets.
So there is a question, At what size does an alist’s performance start to degrade noticeably compared to a hash table?
I have made a simple benchmark with GNU Guile. Here is the code repo:
https://github.com/hardenedlinux/guile-nano-benchmark
Conclusion
- If the size is under 50 elements, you can keep using a-list for the simplicity.
- 50~2000 elements. feel free to optimize it to hashtable, but be careful about premature optimizing. Even a-list is good enough.
- If it's over 2000 elements, you should consider hashtable.