r/programming • • Mar 12 '21

7-Zip developer releases the first official Linux version

https://www.bleepingcomputer.com/news/software/7-zip-developer-releases-the-first-official-linux-version/
5.0k Upvotes

377 comments sorted by

View all comments

125

u/soul_of_rubber Mar 12 '21

I absolutely love 7zip on windows, but how would it compare to gzip on Linux? Does anybody have some data on what would be better? I'm generally interested

151

u/futlapperl Mar 12 '21 edited Mar 12 '21

gzip appears to use the Deflate algorithm. 7z, by default, uses LZMA2, which according to Wikipedia, is an improved version of Deflate. So based on my limited research, 7z should be better. Haven't got any benchmarks, but I think I'll get around to performing some today.

Edit: Someone's tested various algorithms including the aforementioned ones and uploaded a write-up.

105

u/Chudsaviet Mar 12 '21

There is already pretty standard Unix-style (stream) compressor XZ, which uses the same LZMA2.

49

u/futlapperl Mar 12 '21

.xz doesn't seem to be an archive format, instead only supporting single files, so you have to .tar everything first. This explains the common .tar.xz extension. 7z combines those two steps, but so does every other archiving program. Not sure if there are any notable advantages.

130

u/Kissaki0 Mar 12 '21

A 7z will not retain Linux file permissions.

Combining tar with an additional compression is prevalent on Linux. It's also in line with the Unix philosophy of combining/piping programs together.

Tar has a parameter to do the xz step too on compression, and it's no problem on extraction either. So really it's mostly transparent to the user that it's a two layered file compression.

32

u/futlapperl Mar 12 '21

A 7z will not retain Linux file permissions.

Ah, interesting! That's useful to know.

And yeah, I agree, tar sticks to the Unix philosophy of "Do one thing, but do it well." better than 7z.

17

u/Kissaki0 Mar 12 '21

And yeah, I agree, tar sticks to the Unix philosophy of "Do one thing, but do it well." better than 7z.

It’s kind of ironic though how in the next sentence I said tar can do that with a parameter. ;-)

Manually piping and combining things is not very viable to end users. A parameter on a program is much easier to use. Even if the technical implementation will be separated again, the user interface isn’t. I don’t even know if tar embedded the other compression libs statically or uses shared libs or the other binaries.

40

u/Tm1337 Mar 12 '21

I don't want to shoehorn this in, but it is as relevant as it gets.

https://xkcd.com/1168/

6

u/4lteredBeast Mar 13 '21

Funnily enough, xkcd looks like a bunch of parameters you feed the tar command

24

u/barsoap Mar 12 '21

It took literal ages until GNU came around and made tar's x option auto-detect the presence of compression. Before that you had to additionally specify z or j for gz and bzip2, xz is J I think auto-detect has been available for about as long as that.

Hmm. I just tried it, at some point it must also have stopped to operate on /dev/tape if you don't specify a file.

→ More replies (7)

12

u/dreamer_ Mar 12 '21

Manually piping and combining things is not very viable to end users.

Depending on the end user of course ;)

  • Advanced user or developer might need a separate compressor program. Example: when my CI generates extremely large logs, I can just xz them (without tar) - they will be tiny again, because text files compress nicely, and vim will open them anyway (it will decompress them in-memory, I don't need to do it myself).

  • Normal GUI user on Linux does not need to worry about tar, xz, or piping at all. In Gnome: right click on a directory -> Compress -> select .tar.xz -> click "Create"

→ More replies (1)
→ More replies (1)
→ More replies (1)

21

u/spider-mario Mar 12 '21

7-zip lets you choose which files to compress together and with which method. For example, you can have an archive with a bunch of HTML files compressed together with LZMA + a big text file compressed on its own with PPMd + a few PDFs stored without compression. You can then read the TOC without decompressing anything, and if you only need one of the HTML files, you need to decompress the LZMA block that contains them, but you don’t need to care about the PDFs or the PPMd text file. You have flexibility from “each file compressed separately” (.zip) to “everything compressed together” (.tar.whatever), though still at file boundaries I believe.

→ More replies (1)

12

u/Chudsaviet Mar 12 '21

This is exactly what I meant when saying XZ is Unix-style stream compression. In Unix world, its more an advantage I think.

5

u/andynzor Mar 12 '21

The LZMA/XZ archive format was explicitly created to allow using the 7-zip algorithm with *NIX tools (more specifically, to fit more Slackware packages to a CD image). It used the LZMA SDK created by Igor Pavlov himself, with his knowledge and support.

4

u/afiefh Mar 12 '21

I wonder if the inadequacies of the XZ format were ever addressed.

→ More replies (1)
→ More replies (19)

20

u/eyal0 Mar 12 '21

You can't just compare compression ratioa. You have to look at the time spent on operations.

One algorithm can dominate smith is it's better in at least one measure and no worse in all the other measures.

13

u/futlapperl Mar 12 '21

The article I posted takes time spent into consideration.

6

u/smiler82 Mar 12 '21

You can't just compare compression ratioa. You have to look at the time spent on operations.

Which is why we use http://www.radgametools.com/oodlekraken.htm for compressing our bulk content in games.

→ More replies (4)

10

u/stbrumme Mar 12 '21

7zip supports Deflate as well. While *.7z is its default output format, it can generate *.gz files, too. These are actually a little bit smaller than those produced by GZIP and fully compatible to GZIP. (although not as small as Zopfli)

9

u/LinAGKar Mar 12 '21

Don't confuse the 7zip program with the 7z file format. You can use 7z on Linux with other programs (or xz, which also uses lzma), and you can use other file formats with 7zip, including AFAIK gz.

31

u/nrcain Mar 12 '21

You can just look up the compression ratios between the two formats. Gzip (.gz) and 7-zip (.7z) are the exact same thing on both Windows and Linux. So their differences are the same on either platform.

To clarify though: 7z has been available on linux for pretty much as long as the official "7-zip" program has been on Windows. The 7z spec was never closed source I don't think.

So this provides no new capability to Linux really, just another option for the same format that was already supported for a long time.

→ More replies (2)

5

u/Bakoro Mar 12 '21

Here is at least one comparison: https://leadsift.com/7zip-gzip-compression-speed/

It seems like 7zip compresses better, but with more overhead, while gzip(zlib) is much faster overall.

Memory generally isn't a problem these days, so unless you're in some strange restricted environment, using 7zip (or any Lzma derived compression) is probably going to be better overall.

7

u/dreamer_ Mar 12 '21

7zip has better compression ratio than zip and gzip, but that's no wonder really.

In my experience: 7zip is worth using only on Windows really. On Linux we have xz and zstd, and both give better results, sometimes much, much better.

→ More replies (1)

3

u/99drunkpenguins Mar 12 '21

I personally don't think it has a place on linux. We already have 7z extensions for all the main archive managers.

I use 7z files on linux all the time.

It feels odd to have yet another archive manager on linux when we already have dozens of very good ones thst have extensibility to new formats.

→ More replies (8)