Comment by Joker_vD

Comment by Joker_vD a day ago

9 replies

> A static library is nothing but a bundle of object files, wrapped in an ancient and never-quite-standardized archive format.

To this day I'm astonished that it's not just tar. Or pax. Or even cpio! Or literally any file format that has any other use.

sureglymop a day ago

Wasn't there first 'ar' as a general purpose archiver and later 'tar', "tape archiver"?

Why do you find it surprising that the archive format from that time was used to archive a bunch of files?

I wasn't alive but I'm pretty sure ar wasn't only used for this purpose in unix.

  • electroly a day ago

    > Why do you find it surprising that the archive format from that time was used to archive a bunch of files?

    It's surprising because we still use it today, not because it was used at the time.

  • Joker_vD a day ago

    Because e.g. a.out didn't survive and was replaced? Several times, even?

    • sureglymop 17 hours ago

      That is a good point. Although I can only guess, it intuitively makes sense to me why the executable format would more quickly evolve than the archive format which "just works" still.

xyzzy_plugh a day ago

tar/pax are kind of terrible formats. They are hard to implement correctly. I'm glad they are not used more often.

cpio is pretty reasonable though.

zip is actually pretty great and I've been growing increasingly fond of it over the years.

  • Joker_vD a day ago

    The thing is, there is always tar(1) even in the most basic of distributions. And everyone uses tar.gz's or .bz2's or whatever for distributing all kinds of things, so tar is pretty ubiquitous. But the moment you want to do some C development, or any binutils-related, nope, install and use ar(1) which is used for literally one single purpose and nothing else. Because reasons.

    • hyperman1 18 hours ago

      Im not sure how ar does it, but tar has no centralised directory. The only way to get file 100 is to walk trough the 99 files before. This kills random access speed.

  • yjftsjthsd-h a day ago

    > tar/pax are kind of terrible formats. They are hard to implement correctly. I'm glad they are not used more often.

    I'll grant you "kind of terrible", but what's hard to correctly implement about tar? It's just a bunch of files concatenated together with a tiny chunk of metadata stuck on the front of each.

    • electroly 21 hours ago

      Having never done it myself, I don't know, but I do know that the "microtar" library I picked up off GitHub is buggy when expanding GNU Tar archives but perfect when expanding its own archives. Correctly creating one valid archive is a lot easier than reliably extracting all valid archives. The code appeared competent, I assume tar just has a bunch of historical baggage that you can get wrong or fail to implement.