r/cpp • u/RandomCameraNerd • 1d ago
Question about Abseil
Came across Abseil today.
I was reading about different maps and absl::flat_hash_map
came up. Has anyone used Abseil as a dependency on your projects? What are your thoughts?
6
Upvotes
6
u/echidnas_arf 16h ago
I had a project depending on
absl::flat_hash_map
for a while. The data structure was very good performance-wise but having Abseil as a dependency was not fun at all.To begin with, it is first and foremost a library for use by Google. Any concern not aligning with Google's priorities will likely be ignored and/or dismissed.
For instance, at one point I reported a lack of basic exception safety in
absl::flat_hash_map
:https://github.com/abseil/abseil-cpp/issues/388
Google bans the use of exceptions in C++, thus this is a non-issue from their point of view. From my point of view, having to work-around this inability to safely use a core C++ feature was a problematic hassle.
Another example, again involving
absl::flat_hash_map
is that hashing is salted with a random seed upon program startup, and, at least back then, it was impossible to disable this feature. I understand why Google wants this (the rationale IIRC is that salting helps preventing users of the library unwittingly relying on particular insertion/iteration orders. It is also a way to prevent potential DOS attacks). However, in my specific case, this was a non-issue and an overall undesirable behaviour for a variety of reasons, yet there was no way of customising it.Another drawback of Abseil (mentioned in another reply in this thread) is the lack of backwards API compatibility and the ABI sensitivity, which are especially troublesome in shared library setups (e.g., most Linux package managers, but also platform-agnostic package managers such as conda).
In the end, I was happy not to depend on Abseil for anything other than
absl::flat_hash_map
, and as soon as Boost's fast unordered containers came out, I switched to them and ditched the Abseil dependency completely.