logoalt Hacker News

Negitivefragstoday at 5:59 AM3 repliesview on HN

Why is it such a terrible idea?

No need to add complexity, dependancies and reduced performance by using these libraries.


Replies

amlutotoday at 6:05 AM

Lots of reasons:

The code is not portable between architectures.

You can’t actually define your data structure. You can pretend with your compiler’s version of “pack” with regrettable results.

You probably have multiple kinds of undefined behavior.

Dealing with compatibility between versions of your software is awkward at best.

You might not even get amazing performance. mmap is not a panacea. Page faults and TLB flushing are not free.

You can’t use any sort of advanced data types — you get exactly what C gives you.

Forget about enforcing any sort of invariant at the language level.

show 1 reply
lifthrasiirtoday at 6:05 AM

No defined binary encoding, no guarantee about concurrent modifications, performance trade-offs (mmap is NOT always faster than sequential reads!) and more.

show 1 reply
jraphtoday at 6:06 AM

Because a struct might not serialize the same way from a CPU architecture to another.

The sizes of ints, the byte order and the padding can be different for instance.

show 1 reply