Live data from Hacker News

Show HN: Hexi – Modern header-only network binary serialisation for C++

github.com

11–20 of 49 posts

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#11
By the way I looked through the code, and had to read about metaprogramming in C++. I wonder why is it so complicated? For example, why constraints like std::is_integral are represented by structs. Doesn't make much sense to me. A function wouldn't be better here?

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#12
post #10

Your lib requires manually creating both a serializing and deserializing function. If the functions are out of sync, bad things happen. Consider copying Cereal, which solves this problem by requiring you to create a single templated function ( https://uscilab.github.io/cereal/ )

Thanks, that is definitely a downside to the shift operator overloading approach. I'll take that onboard and investigate whether a single operator to handle both would mesh with the current design.

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#14

By the way I looked through the code, and had to read about metaprogramming in C++. I wonder why is it so complicated? For example, why constraints like std::is_integral are represented by structs. Doesn't make much sense to me. A function wouldn't be better here?

Because the only way to do metaprogramming in C++ is via the type system. Thismakes it so you need to implement 'functions' as types.

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#15

I know it's a convention since the inception of the language, but the operator overload abuse of the bitshift operator still makes me sad every time I see it :(

On the plus side, it's optional. The same thing can be achieved with put()/get() equivalents.

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#16
post #6

Wow that api looks fantastic! Bravo! I'd like to read an even more thorough overview of how it works and all the gotchas before I'd consider using this 'in production' but the API looks very easy to use and very elegant. EDIT: just hit the section on portability, seems like you would always have to use that API, yeah? I feel like when you are writing network code you simply have to make it portable from the get-go. I…

Thanks. The documentation could definitely be fleshed out with some more examples. You'd likely want to always use that API (or layer something on top of it) unless you're in control of both ends and know they were built with the same toolchain & settings. One area where I've skipped over it is by writing a basic code gen tool (albeit unfinished as most personal projects) that generates the serialisation functions at…

That code-gen would be fantastic. I have commercial applications for this, so I'll keep an eye on your space.

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#17
post #10

Your lib requires manually creating both a serializing and deserializing function. If the functions are out of sync, bad things happen. Consider copying Cereal, which solves this problem by requiring you to create a single templated function ( https://uscilab.github.io/cereal/ )

Thanks, that is definitely a downside to the shift operator overloading approach. I'll take that onboard and investigate whether a single operator to handle both would mesh with the current design.

like boost serialize, which overloads the & operator

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#18

By the way I looked through the code, and had to read about metaprogramming in C++. I wonder why is it so complicated? For example, why constraints like std::is_integral are represented by structs. Doesn't make much sense to me. A function wouldn't be better here?

Practically, it's all through this `type_traits` header that (often) end up in unreadable messes. It's all possible because of the catchy acronym SFINAE. It doesn't make much sense to me either, so I avoid it :)

https://en.cppreference.com/w/cpp/language/sfinae

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#19

I know it's a convention since the inception of the language, but the operator overload abuse of the bitshift operator still makes me sad every time I see it :(

You are not alone. many on the standard committee are trying to get rid of it. std::print is the new way to do io instead of cout in part so you don't have to abuse shift for io. This is new in c++23 though so few people know about it.

Bjarne appears to prefer cout though, so it isn't universal.

Re: Show HN: Hexi – Modern header-only network binary serialisation for C++

#20
post #18

By the way I looked through the code, and had to read about metaprogramming in C++. I wonder why is it so complicated? For example, why constraints like std::is_integral are represented by structs. Doesn't make much sense to me. A function wouldn't be better here?

Practically, it's all through this `type_traits` header that (often) end up in unreadable messes. It's all possible because of the catchy acronym SFINAE. It doesn't make much sense to me either, so I avoid it :) https://en.cppreference.com/w/cpp/language/sfinae

You don't really need to use sfinae anymore, concepts are cleaner and easier to follow, also this library appears to use concepts
Post reply on HN