this post was submitted on 27 Sep 2024
97 points (81.7% liked)

Showerthoughts

29827 readers
846 users here now

A "Showerthought" is a simple term used to describe the thoughts that pop into your head while you're doing everyday things like taking a shower, driving, or just daydreaming. A showerthought should offer a unique perspective on an ordinary part of life.

Rules

  1. All posts must be showerthoughts
  2. The entire showerthought must be in the title
  3. Avoid politics
    • 3.1) NEW RULE as of 5 Nov 2024, trying it out
    • 3.2) Political posts often end up being circle jerks (not offering unique perspective) or enflaming (too much work for mods).
    • 3.3) Try c/politicaldiscussion, volunteer as a mod here, or start your own community.
  4. Posts must be original/unique
  5. Adhere to Lemmy's Code of Conduct

founded 1 year ago
MODERATORS
top 47 comments
sorted by: hot top controversial new old
[–] [email protected] 73 points 2 months ago (1 children)

Or a renamed txt. Eg, .js, .py, .css, .html, .json

[–] [email protected] 60 points 2 months ago (2 children)

Thank God they went with file name extensions so we didn't have to preface every source .txt file with header content to instruct the editor about what kind of content it would have.

[–] [email protected] 48 points 2 months ago (2 children)
[–] [email protected] 8 points 2 months ago

Oh dear God

[–] [email protected] 7 points 2 months ago (4 children)

Why do I need to put that at the start of bash, desktop, and html files then?

[–] [email protected] 14 points 2 months ago (1 children)

Because both ways are used. Microsoft relies on file names, linux on the first bytes of the file.

[–] [email protected] 20 points 2 months ago* (last edited 2 months ago) (1 children)

Not quite correct. For html, that is to signal standard compliance, you can leave it away and the browser will still handle it. For the bash one, all (most) shell scripts use .sh, so you need to give a shebang to tell the loader which executable (sh, bash, zsh, csh, ...) to use

Also on Linux xdg does take file extensions into account, just executables do not

[–] [email protected] 5 points 2 months ago

You're right, my comment was oversimplified.

[–] [email protected] 5 points 2 months ago

For shell scripts it's because bash isn't the only shell; if you leave out the shebang line, Ubuntu will run your script in Dash instead

[–] [email protected] 4 points 2 months ago* (last edited 2 months ago)

For HTML, it’s to distinguish “standards mode” HTML from “quirks mode” HTML (which doesn’t need a header).

[–] [email protected] 1 points 2 months ago (1 children)

Nothing unless you want to serve them without some other way to see what file type they are.

You can run bash scripts with bash.

Don't know what a desktop file is.

HTML has that because webservers used to not have auto media type detection and response headers.

[–] [email protected] 4 points 2 months ago

.desktop files are a Linux/Unix thing. Basically, it's a fancy shortcut, usually to an application, which allows specifying additional infos, like e.g. translated names.
In particular, the contents of the application menu are defined by just a folder filled with .desktop files.

https://en.wikipedia.org/wiki/Shortcut_(computing)#Unix

[–] [email protected] 45 points 2 months ago* (last edited 2 months ago) (3 children)

AKA “Why zip doesn’t compress things much any more”.

[–] [email protected] 16 points 2 months ago (1 children)

I see images, audio, or video files distributed in zips far too often. You're getting maybe a percent of compression if you're lucky; just distribute the raw files or use a non-compressed bundle format like tar.

[–] [email protected] 21 points 2 months ago (3 children)
[–] [email protected] 21 points 2 months ago

tar -xzvf filename

With a bad pretend accent:

Xtract

Zee

Vucking

File

[–] [email protected] 19 points 2 months ago

The cheeky option:

tar -h

Or is it tar --help? Oh no...

[–] [email protected] 4 points 2 months ago

tar -cf stop-nuke.tar

[–] [email protected] 2 points 2 months ago (2 children)
[–] [email protected] 9 points 2 months ago (1 children)

Zipping a file repeatedly typically doesn’t reduce the size further after the first time.

[–] [email protected] 2 points 2 months ago

Yeah duoy you [realistically] can't compress compressed data...

[–] [email protected] 3 points 2 months ago

Not sure what the original point was but curiously I happened to use file on a an Apple .numbers file recently and found that it was a .zip file in disguise with zero compression.

So maybe the point was that it’s used often as a container format more often than it’s used for compression? Just my (unrelated) general computer work would also suggest this.

[–] [email protected] 0 points 2 months ago* (last edited 2 months ago)

My 1.5gb log folders disagrees. But I never tried opening a .txt in 7-zip.

[–] [email protected] 24 points 2 months ago (1 children)

Your MOM is a renamed zip!

And if not, wow, she really kept herself in shape. Very good.

[–] [email protected] 2 points 2 months ago

She keeping them filled tight if you know what I mean

[–] [email protected] 18 points 2 months ago

Counterpoint: what?

[–] [email protected] 16 points 2 months ago (1 children)

Not really. The "file types" you're talking about are expected to contain whatever things in a very specific format.

You're really just saying "many file types use an efficient and common compression algorithm". Which is correct, obvious, and to be expected.

[–] boletus 2 points 1 month ago (1 children)

A .docx is just a zip file with xml documents in it.

[–] [email protected] 1 points 1 month ago (1 children)

What happens if I put an mp3 or an epub file in there with the xml? Is it still a word document?

[–] boletus 1 points 1 month ago (1 children)

Maybe, I was just giving an example. Like Java jar files are just zip files with other jars in them.

[–] [email protected] 1 points 1 month ago

My point is that the formats we're talking about define the content. Like it's not "just a zip file" merely because it's compressed. The format defines the data that may be included.

[–] [email protected] 10 points 2 months ago (5 children)

I don't get it... I must be missing something about zipped files.

[–] [email protected] 35 points 2 months ago* (last edited 2 months ago)

You're not missing much. A few modern file types are zips with expected folder structures, especially MSOffice files. But this is nowhere near universally true.

You can open a file in your text editor of choice and if you see it start with PK (for Phil Katz the creator of the format and the original PKZIP/PKUNZIP programs) then it's probably a zip.

Also, by the logic of the OP, all DLLs are EXEs.

[–] [email protected] 21 points 2 months ago (2 children)

OP refers to the fact that you can rename some filetypes to .zip and unpack them.

Notable examples microsoft office files (.docx) or android apps (.apk).

Counterexample are media files (mp3, mp4, jpg).

[–] [email protected] 7 points 2 months ago

Notably, java jar files as well.

[–] [email protected] 1 points 2 months ago (1 children)

OP refers to the fact that you can rename some filetypes to .zip and unpack them.

So... you mean the zip program just rename them back? Why?

[–] [email protected] 14 points 2 months ago (1 children)

I think it makes sense from a programming view. When you have a document, you can add all the media files and pack them together as one archive. Then the program sets the filename to .docx so everyone knows that they need an office program to open that file.

For the users, all you need to know is what program can open which files. If every document would be named .zip, you would have no idea if it was a spreadsheet or slides for your presentation.

[–] [email protected] 2 points 2 months ago (2 children)

I got that from the other answers. I was just very confused why I'd have to rename them to ".zip".

I still don't get why it is "most" files.

[–] [email protected] 8 points 2 months ago

I don't think "most" applies here. Text-based files, pdf, media files and most executeable files are not .zip.

[–] [email protected] 3 points 2 months ago (1 children)

You don't have to rename them, doing so would just make windows default to using the builtin zip extractor.

If you have 7-zip you can just right click the file you wan to explore and try to extract it.

[–] [email protected] 1 points 2 months ago

Ah, right, that is how windows works.

[–] [email protected] 12 points 2 months ago

There are basically two types of files. Text files and binary files.

Most information are stored in text files so humans can easily understand it, and it's easier to find errors, review, parse. But text storage takes more space than binary files. And many complicated softwares normally need multiple text files or data files, many of them just store them together as a zip file so that it's easier to handle. Examples are .docx,.pptx, etc files in MS Office, try unzipping them and see what they contain. Zipping also has advantages of reducing file sizes.

[–] [email protected] 10 points 2 months ago

Take a .docx file, using 7-zip, exctract it.

You will get an entire folder structure with several files inside the .docx file.

What OP means is that several programs use a zip file as a container for all the stuff they need in a save file.

The file extention is just a name for the OS to find the proper program to open the file.

[–] [email protected] 4 points 2 months ago (1 children)

OK, thanks for all the answers. I get it, a "docx" is a zip archive expected to contain something specific making it a docx. But why "most" though?

[–] [email protected] 4 points 2 months ago (1 children)

I think 'most' is hyperbole for dramatic effect / increased engagement. "more files than you might think are actually following the zip file structure" isn't as punchy.

[–] [email protected] 3 points 2 months ago

I just didn't think of too many file extensions when I had this thought. I was also thinking of more obscure file extensions, and not the main media formats.