Explain a bit more the difference between Hashtbl and Maps#3631
Open
LordPatate wants to merge 2 commits into
Open
Explain a bit more the difference between Hashtbl and Maps#3631LordPatate wants to merge 2 commits into
LordPatate wants to merge 2 commits into
Conversation
The current introduction mentions multiple differences to chose one or the other but only gives one advantage to Hashtbl. It is not obvious why would one chose Maps over Hashtbl.
Discuss a little bit more the differences, especially the advantages over Hashtbl, without going too much into the details. The advantages of Maps were never mentioned, while the main advantage of Hashtbl was present in their own page. Unless the reader dived into the library or did their own research on self-balancing binary search trees, Maps could seem like a "worse" Hash Table; or only exist for the functional interface.
cuihtlauac
requested changes
Apr 29, 2026
Collaborator
cuihtlauac
left a comment
There was a problem hiding this comment.
Thanks @LordPatate. Make sure to only use capitals for standard library module names or tutorial titles, data structures don't need them
| on [Hash Tables](/docs/hash-tables). | ||
| Maps offer a functional interface that Hash Tables do not | ||
| and maintain total ordering of the keys, allowing more operations; | ||
| while Hash Tables have better search performance on average. |
Collaborator
There was a problem hiding this comment.
Suggested change
| while Hash Tables have better search performance on average. | |
| while hash tables have better search performance on average. |
|
|
||
| For a different implementation of an association table in OCaml's Standard Library, see the tutorial | ||
| on [Hash Tables](/docs/hash-tables). | ||
| Maps offer a functional interface that Hash Tables do not |
Collaborator
There was a problem hiding this comment.
Suggested change
| Maps offer a functional interface that Hash Tables do not | |
| `Map` offer a functional interface that `Hashtbl` do not |
| table`](https://en.wikipedia.org/wiki/Hash_table) is able to retrieve | ||
| information at a nearly instantaneous constant time complexity (O(1)). | ||
|
|
||
| **Note:** For more details on the differences between Hash Tables and Maps, |
Collaborator
There was a problem hiding this comment.
Suggested change
| **Note:** For more details on the differences between Hash Tables and Maps, | |
| **Note:** For more details on the differences between hash tables and associative maps, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current Hashtbl introduction mentions multiple differences to chose one or the other, but only gives one advantage to Hashtbl.
It is not obvious why would one chose Maps over Hashtbl.
The advantages of Maps were never mentioned, while the main advantage of Hashtbl was present in their own page.
Unless the reader dived into the library or did their own research on self-balancing binary search trees, Maps could seem like a "worse" Hash Table; or only exist for the functional interface.
I tried adding a little more information without going into too much detail and referenced Wikipedia for more.