684
submitted 10 months ago by [email protected] to c/[email protected]
top 50 comments
sorted by: hot top controversial new old
[-] [email protected] 97 points 10 months ago

There are 3 types of files. Renamed txt, renamed zip, and exe

[-] [email protected] 53 points 10 months ago* (last edited 10 months ago)

I'd argue with this, but it seems like image and video file extensions have become a lawless zone with no rules so I don't even think they count.

[-] [email protected] 30 points 10 months ago

Looking at you, .webp

[-] [email protected] 18 points 10 months ago* (last edited 10 months ago)

Video files are just a bunch of zip files in a trenchcoat.

[-] fibojoly 8 points 10 months ago* (last edited 10 months ago)

Back in the day, when bandwidth was precious and porn sites would parcel a video into 10 second extracts, one per page, you could zip a bunch of these mpeg files together into an uncompressed zip, then rename it .mpeg and read it in VLC as a single video. Amazing stuff.

[-] [email protected] 5 points 10 months ago

What's it called when you logically expect something to work, but are totally surprised that it actually does?

[-] fibojoly 6 points 10 months ago

Sounds an awful lot like a normal day at work as a dev.

[-] [email protected] 17 points 10 months ago
[-] [email protected] 9 points 10 months ago

It's a folder that you put files into, but acts as a file itself. Not at all like zip.

load more comments (2 replies)
[-] [email protected] 4 points 10 months ago

Isn't the Windows exe also a renamed zip?

[-] [email protected] 16 points 10 months ago* (last edited 10 months ago)

See, ZIP files are strange because unlike most other archive formats, they put the "header" and table of contents at the end, and all of the members (files within the zip file) are listed in that table of contents as offsets relative to the start of the file. There's nothing that says that the first member has to begin at the start of the file, or that they have to be contiguous. This means you can concatenate an arbitrary amount of data at the beginning of a ZIP file (such as an exe that opens its argv[0] as a zip file and extracts it) and it will still be valid. (Fun fact! You can also concatenate up to 64KiB at the end and it will still be valid, after you do some finagling. This means that when a program opens a ZIP file it has to search through the last 64KiB to find the "header" with the table of contents. This is why writing a ZIP parser is really annoying.)

As long as whatever's parsing the .exe doesn't look past the end of its data, and whatever's parsing the .zip doesn't look past the beginning of its data, both can go about their business blissfully unaware of the other's existence. Of course, there's no real reason to concatenate an executable with a zip file that wouldn't access the zip file, but you get the idea.

A common way to package software is to make a self-extracting zip archive in this manner. This is absolutely NOT to say that all .exe files are self extracting .zip archives.

[-] [email protected] 10 points 10 months ago* (last edited 10 months ago)

No. But the Windows office suite is
You can rename a docx and extract it.
Don't know how it is with ppt/x and xls/x

[-] [email protected] 8 points 10 months ago

xls & co. (the older ones) are something custom. Only after standardization as OOXML (a shitshow btw, there's a lengthy wiki article about it) they got zip.

[-] [email protected] 4 points 10 months ago

The whole Word and Libre/OO-Writer world is a shit show.
So complex and everyone decides to interpret it a bit differently.
Not even Libre and OO can be interoperabel between the same file and feature.

[-] [email protected] 5 points 10 months ago

docx are mostly markup language, actually. Much like SVGs and PDFs.

load more comments (5 replies)
load more comments (2 replies)
[-] [email protected] 87 points 10 months ago

Ah, good ol' Microsoft Office. Taken advantage of their documents being a renamed .zip format to send forbidden attachments to myself via email lol

On the flip side, there's stuff like the Audacity app, that saves each audio project as an SQLite database 😳

[-] [email protected] 50 points 10 months ago

Also .jar files. And good ol' winamp skins. And CBZ comics. And EPUB books. And Mozilla extensions. And APK apps. And...

[-] [email protected] 27 points 10 months ago

an SQLite database

Genius! Why bother importing and exporting

[-] [email protected] 20 points 10 months ago

Minetest (an open-source Minecraft-like game) uses SQLite to save worlds.

[-] [email protected] 8 points 10 months ago

Mineclone2 is an absolute masterpiece of a game for Minetest IMO

[-] [email protected] 9 points 10 months ago

I prefer games that embrace the difference from Minecraft instead of trying to emulate it. My favorite is MeseCraft.

load more comments (1 replies)
load more comments (1 replies)
[-] [email protected] 23 points 10 months ago

SQLite is amazing. Shush.

[-] [email protected] 17 points 10 months ago

that saves each audio project as an SQLite database 😳

Is this a problem? I thought this would be a normal use case for SQLite.

[-] [email protected] 16 points 10 months ago

doesn't sqlite explicitly encourage this? I recall claims about storing blobs in a sqlite db having better performance than trying to do your own file operations

[-] [email protected] 8 points 10 months ago* (last edited 10 months ago)

Thanks for the hint. I had to look that up. (The linked page is worth a read and has lots of details and caveats.)

The scope is narrow, and well documented. Be very wary of over generalizing.

The measurements in this article were made during the week of 2017-06-05 using a version of SQLite in between 3.19.2 and 3.20.0. You may expect future versions of SQLite to perform even better.

https://www.sqlite.org/fasterthanfs.html

SQLite reads and writes small blobs (for example, thumbnail images) 35% faster¹ than the same blobs can be read from or written to individual files on disk using fread() or fwrite().

Furthermore, a single SQLite database holding 10-kilobyte blobs uses about 20% less disk space than storing the blobs in individual files.)

Edit 5: consolidated my edits.

[-] OrangeXarot 7 points 10 months ago
load more comments (1 replies)
[-] [email protected] 62 points 10 months ago

Also renamed xml, renamed json and renamed sqlite.

[-] [email protected] 18 points 10 months ago

Those sound fancy, I just use renamed txt files.

[-] [email protected] 9 points 10 months ago

Amateurs.

I have evolved from using file extensions, and instead, don't use any extension!

[-] [email protected] 18 points 10 months ago

I don’t even use a file system on my storage drives. I just write the file contents raw and try to memorize where.

[-] [email protected] 10 points 10 months ago

Sounds tedious, I've just been keeping everything in memory so I don't have to worry about where it is.

load more comments (3 replies)
[-] [email protected] 4 points 10 months ago* (last edited 10 months ago)

I use mime. Because magic bit.

load more comments (5 replies)
[-] [email protected] 8 points 10 months ago* (last edited 10 months ago)

SQLite explicitly encourages using it as an on-disk binary format. The format is well-documented and well-supported, backwards compatible (there's been no major version changes since 2004), and the developers have promised to support it at least until the year 2050. It has quick seek times if your data is properly indexed, the SQLite library is distributed as a single C file that you can embed directly into your app, and it's probably the most tested library in the world, with something like 500x more test code than library code.

Unless you're a developer that really understands the intricacies of designing a binary data storage format, it's usually far better to just use SQLite.

[-] [email protected] 4 points 10 months ago

Use binwalk on those

load more comments (2 replies)
[-] [email protected] 39 points 10 months ago

Nothing wrong with that... Most people don't need to reinvent the wheel, and choosing a filename extension meaningful to the particular use case is better then leaving it as .zip or .db or whatever.

[-] [email protected] 5 points 10 months ago

Totally depends on what the use case is. The biggest problem is that you basically always have to compress and uncompress the file when transferring it. It makes for a good storage format, but a bad format for passing around in ways that need to be constantly read and written.

Plus often we're talking plain text files being zipped and those plain text formats need to be parsed as well. I've written code for systems where we had to do annoying migrations because the serialized format is just so inefficient that it adds up eventually.

[-] [email protected] 23 points 10 months ago

When i discovered as a little kid that apk files are actually zips i felt like a detective.

[-] [email protected] 13 points 10 months ago
[-] [email protected] 13 points 10 months ago
[-] [email protected] 5 points 10 months ago

They both have their use cases. Zstandard is for compression of a stream of data (or a single file), while 7-Zip is actually two parts: A directory structure (like tar) plus a compression algorithm (like LZMA which it uses by default) in a single app.

7-Zip is actually adding zstd support: https://sourceforge.net/p/sevenzip/feature-requests/1580/

load more comments (3 replies)
[-] [email protected] 4 points 10 months ago

I'll gunzip you to oblivion!

load more comments (7 replies)
load more comments
view more: next ›
this post was submitted on 13 Sep 2023
684 points (97.6% liked)

Programmer Humor

31331 readers
14 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS