Hasty Briefsbeta

Bilingual

The Best C++ Library

10 months ago
  • #Programming
  • #C++
  • #Standard Library
  • The author criticizes the C++ standard library for being outdated, wordy, and difficult to use, citing issues with associative containers, `std::optional`, `std::variant`, and iterator pairs.
  • They propose a new C++ library called `best`, designed to be a modern, user-friendly alternative to the standard library, inspired by Rust, Go, and other languages.
  • `best` includes foundational components like type traits, metaprogramming utilities, and algebraic data types (`best::row`, `best::choice`, `best::option`, `best::result`).
  • Memory and pointer operations are handled by `best::ptr`, `best::box`, and `best::span`, which offer safer and more intuitive APIs compared to raw pointers and `std::span`.
  • Iterators in `best` are modeled after Rust's `Iterator` trait, providing a more ergonomic and efficient way to work with sequences.
  • Heap containers like `best::vec` and `best::table` (a hash table) are designed with small vector optimizations and customizable allocators.
  • Text handling in `best` is UTF-8 focused, with `best::str` and `best::strbuf` providing robust Unicode support and encoding flexibility.
  • Formatting is done via a Rust-like `format!` macro, with compile-time format string validation and extensible formatting for user-defined types.
  • Reflection capabilities allow introspection of struct and enum fields, enabling generic operations like default formatting for aggregates.
  • The library includes a unit testing framework (`best::test`) and a CLI parser (`best::cli`), both designed to be macro-free and easy to use.
  • Future plans for `best` include adding synchronization primitives, I/O, math libraries, SIMD support, and OS APIs like signals and networking.
  • The author sees `best` as a proof-of-concept for how C++ could be improved, though they don't expect widespread adoption.