Hexi is a new, header-only C++ library for network binary serialization. It focuses on modern C++ features, aiming for ease of use, safety, and performance. Hexi supports user-defined types, standard containers, and common data structures out-of-the-box, minimizing boilerplate. It leverages compile-time reflection and constexpr processing to achieve efficiency comparable to hand-written serialization code, while providing a more concise and maintainable solution.
Bjarne Stroustrup's "21st Century C++" blog post advocates for modernizing C++ usage by focusing on safety and performance. He highlights features introduced since C++11, like ranges, concepts, modules, and coroutines, which enable simpler, safer, and more efficient code. Stroustrup emphasizes using these tools to combat complexity and vulnerabilities while retaining C++'s performance advantages. He encourages developers to embrace modern C++, utilizing static analysis and embracing a simpler, more expressive style guided by the "keep it simple" principle. By moving away from older, less safe practices and leveraging new features, developers can write robust and efficient code fit for the demands of modern software development.
Hacker News users discussed the challenges and benefits of modern C++. Several commenters pointed out the complexities introduced by new features, arguing that while powerful, they contribute to a steeper learning curve and can make code harder to maintain. The benefits of concepts, ranges, and modules were acknowledged, but some expressed skepticism about their widespread adoption and practical impact due to compiler limitations and legacy codebases. Others highlighted the ongoing tension between embracing modern C++ and maintaining compatibility with existing projects. The discussion also touched upon build systems and the difficulty of integrating new C++ features into existing workflows. Some users advocated for simpler, more focused languages like Zig and Jai, suggesting they offer a more manageable approach to systems programming. Overall, the sentiment reflected a cautious optimism towards modern C++, tempered by concerns about complexity and practicality.
Summary of Comments ( 38 )
https://news.ycombinator.com/item?id=43508061
HN commenters generally praised Hexi for its simplicity and ease of use, particularly its header-only nature and intuitive syntax. Some compared it favorably to other serialization libraries like Protobuf and Cap'n Proto, highlighting its potential for better performance in certain scenarios due to its zero-copy deserialization. Concerns were raised about potential compile-time impact due to the header-only design and the lack of documentation beyond basic examples. One commenter suggested incorporating compile-time reflection to further enhance the library's capabilities and reduce boilerplate. Others questioned the long-term viability of the project, expressing a desire to see more real-world use cases and benchmarking data. The lack of support for optional fields was also mentioned as a potential drawback.
The Hacker News post about Hexi, a header-only network binary serialization library for C++, generated several comments discussing its merits and drawbacks compared to existing solutions.
One commenter expressed skepticism about the value proposition of Hexi, questioning the need for yet another serialization library in C++. They pointed out the maturity and wide adoption of Protobuf and Cap'n Proto, suggesting that unless Hexi offered significant performance or usability advantages, it would struggle to gain traction. This commenter also highlighted the importance of schema evolution in real-world applications and inquired about Hexi's capabilities in this area.
Another user echoed this sentiment, mentioning FlatBuffers and Cereal as additional alternatives already available. They specifically mentioned the complexity of handling schema evolution and backward compatibility, implying that these are crucial considerations for any serialization library. They also raised the issue of handling untrusted input, emphasizing the importance of security and robust error handling when deserializing data from potentially malicious sources.
A different commenter focused on the potential benefits of Hexi's header-only nature, suggesting that it could simplify integration and reduce build times compared to libraries requiring separate compilation and linking steps. However, they also acknowledged that this advantage might be offset by increased compile times due to the inclusion of the entire library in every translation unit.
Another comment discussed the importance of zero-copy deserialization for performance-sensitive applications, asking whether Hexi supports this feature. Zero-copy deserialization allows data to be used directly from the serialized buffer without requiring a separate copying step, which can significantly improve efficiency.
Several commenters inquired about specific features and capabilities of Hexi, such as support for optional fields, default values, and different data types. They also discussed the library's API design and ease of use, comparing it to other serialization libraries.
One commenter provided a link to a benchmark comparing various serialization libraries, including Protobuf, Cap'n Proto, and FlatBuffers. This benchmark could be useful for evaluating Hexi's performance relative to its competitors.
Finally, the author of Hexi actively participated in the discussion, responding to questions and clarifying various aspects of the library's design and functionality. They addressed concerns about schema evolution, security, and performance, providing additional context and insights into the library's development. They also expressed openness to feedback and suggestions for improvement.