Live data from Hacker News

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

github.com

31–40 of 49 posts

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

#32

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.

What does that mean, and is it even true, given template value parameters or constexpr for example?

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

#34

Earlier quoted context omitted.

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

What does that mean, and is it even true, given template value parameters or constexpr for example?

Sure, auto constexpr stuff can express some things. Not most things though, at least in my experience. Perhaps a skill issue on my part. Or things might have changed again. I'm "still" using C++20 after all.

> What does that mean

Have you ever noticed that the (compile time) "rules" for interacting with templated functions are somewhat different from those of non-templated functions? I don't know if "functions as types" is entirely fair but there is definitely some weirdness.

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

#36

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 :(

>operator overload abuse

Array programming languages smugly enter the chat

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

#38

If you need schema-less serialiation there’s MessagePack. But soon you’ll be bitten by the fact you don’t have a schema and so you’ll move to something like Protobuf or the more efficient FlatBuffers

Agreed but just to clarify, Hexi sits at a level below something like MessagePack because it doesn't impose any particular encoding on you since the use-case was handling arbitrary binary protocols that you might not have any control over. You could build support for MessagePack on top of Hexi but not the other way around. They're all very different use-cases.

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

#39

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.

While this is true, you can do so much these days with functions with 'auto' return types (function templates), constexpr functions/lambdas and "if constexpr"
Post reply on HN