r/programming • • Feb 27 '16

AppImage: Linux apps that run anywhere

http://appimage.org/
794 Upvotes

208 comments sorted by

View all comments

55

u/marmulak Feb 27 '16

How does this differ from static linking? I use Telegram Desktop, which I just download from Telegram's page and run. It works perfectly, because it's a statically linked executable and is like 20 freaking megs.

The reason why this is a bad idea for programs is because imagine a library which every program uses. Let's say the library is 5 megs, and you have 100 programs that use it. With dynamic linking we're talking like less than 100 megs. Maybe less than 50, or less than 10. (One exe could be just a few kilobytes.) with static linking we're talking more than 500mb wasted. It could actually get worse than this with larger libraries and multiple libraries.

So yeah, it's OK to waste a little disk space for a handful of apps, but it's a bad approach to system design. A good Linux distro offers a good repository of dynamically linked packages, and ideally you wouldn't need to download apps from 3rd parties except for the odd couple of things.

0

u/[deleted] Feb 27 '16

[deleted]

12

u/cosmo7 Feb 27 '16

I think the solution to DLL hell was SXS.

6

u/[deleted] Feb 27 '16

Except it didn't. IIRC side by side carries a lot of additional troubles (in particular with permissions). The biggest problem I found with windows and DLLs is the search order.

6

u/marmulak Feb 27 '16

SXS makes everything better

45

u/ggtsu_00 Feb 27 '16 edited Feb 27 '16

SXS is the reason your C:\Windows folder is over 40GB after about a year of updates.

0

u/[deleted] Feb 27 '16

[deleted]

→ More replies (4)

3

u/gospelwut Feb 28 '16

Really? I Thought DLL hell was more-so dealing with the GAC. People object to packages shipping with their DLLs in their path?

0

u/[deleted] Feb 28 '16

[deleted]

→ More replies (4)
→ More replies (8)

31

u/sprash Feb 27 '16

This is not real static linking. It is the worst of both worlds.

Real static linking can be far superior to dynamic linking in many ways (as explained here ). Especially if you have huge libs (like KDE and Gnome) but programs use only very little functionality from them. If you start e.g. Kate you have to load all of the KDElib bloat as well, even though Kate maybe never uses more than 10% of the provided functionality. With real static linking the compiler handpicks the functions you need and only includes that in the binary.

12

u/Chandon Feb 27 '16

you start e.g. Kate you have to load all of the KDElib bloat as well, even though Kate maybe never uses more than 10% of the provided functionality.

Nonsense.

Virtual address space exists, and shared objects are "loaded" by mapping them into virtual memory. The shared lib can be 40 gigs, and if you use only one function from it it'll cost you 4k of actual RAM.

→ More replies (4)

4

u/marmulak Feb 27 '16

Yeah that does sound awesome

2

u/dorfsmay Feb 27 '16

Interesting... Never heard of µClibc before, and it's now the second time this week.

10

u/sprash Feb 27 '16

Nowadays there is musl which seems to be the best in comparison to major C/POSIX standard library implementations.

→ More replies (1)

2

u/KnowLimits Feb 27 '16

It's still demand paged, though, so it's not like you're loading the entire KDElib off the disk if you don't need to. (And besides, it's probably already in memory anyway.)

2

u/probonopd Feb 28 '16

You can put applications that have been statically linked into an AppImage, as you can do with apps that have been dynamically linked. An AppImage is really just a filesystem that gets mounted at runtime.

23

u/b169118 Feb 27 '16

Also I was thinking this could be useful for abondonwares which are especially common in academia.

11

u/balloonanimalfarm Feb 27 '16

If you're looking for something a little easier check out CDE.

You run a program and it records all the resources it uses (libraries, executables, files, environment variables, etc.) and packages them all together so you have repeatable executions. It was primarily built so experiments could be repeated on different machines.

→ More replies (2)

10

u/[deleted] Feb 27 '16

There are a few problems with static linking, and I am not talking about the usual ones (size, updates).

  1. if you have a library that is a double dependency, you might end up risking a double inclusion. That doesn't sound a lot of trouble, until you consider that some libraries have internal state. I once encountered this situation with MPI. the MPI library got linked twice into the executable because it was both a direct dependency, and an indirect one. Unfortunately, when you called MPI_Init, it initialized one and not the other (because it's a different copy), meaning you would have crashes and random behavior. Same for handles (e.g. comms identifiers) that are created by one copy and passed to the other. Won't work.

  2. you can't dlopen a static link. This may not sound again a big deal, but sometimes it is. Sometimes you want to dlopen a library, and dlclose it

  3. sometimes, even if you link static, it does not guarantee it will run. ABI changes, kernel differences, will throw a wrench in a static package.

  4. some libraries are a complete nightmare to build/link static.

  5. if you go static, you have to go static, meaning that you need the static version of every library you want to link against. Again, some libraries do provide static versions, others don't and you have to build them yourself.

4

u/puddingcrusher Feb 27 '16 edited Feb 27 '16

Let's say the library is 5 megs, and you have 100 programs that use it. With dynamic linking we're talking like less than 100 megs. Maybe less than 50, or less than 10.

I have 4 TB of disk, and 32 GB of RAM, and either cost less than $250 each. Libraries have not significantly increased in size in the last two decades, but my machine's space has grown exponentially. 500 MB wasted does not concern me at all.

I will happily trade space for convenience every time, because space is super cheap, but my time is valuable, especially when I have to spend it with tracking down the correct dependencies, which can be incredibly frustrating. If you've ever spent a work-day or two in DLL-Hell, you start looking at this approach favourably. In another decade, when ever crappy phone has 64 GB of RAM out of the box, and compiled code is 10% bigger than now, this makes even more sense. Fuck saving space if we can solve all dependency issues easily instead.

So yeah, it's OK to waste a little disk space for a handful of apps, but it's a bad approach to system design.

Have the base system be streamlined and optimized, then solve compatibility issues by throwing memory at the problem. When an app becomes super widely used, include it or its libraries in the system when it is mature. Fast easy development and growth first, then long-term stability and performance. What a wonderful world!

3

u/marmulak Feb 28 '16

I hear you. Actually, I think a balanced approach might be ideal, where system maintainers should streamline the base system and utilities as much as they can, and then something like AppImage can be used to handle end-user applications–the sort of things people might want to download for personal use.

For example, I avoid 3rd party apps on Linux like the plague. However, I had a really good experience with Telegram Desktop, which I am pretty sure is statically linked, and I don't really mind that the whole app is 20 megs. It's just one app, and it self-updates so it's really nice having the bleeding edge version straight from the dev since the project is very active. Same thing with Chrome–I use the RPM repo, but the RPM itself is like 50 megs, so there's no secret there that they statically linked or included their own libraries to make it so large.

I don't miss the disk space, although it's kind of inconvenient to update over my slow Internet connection. As for RAM usage, I'm not sure how that comes into play. I sort of do need the RAM, but this laptop is more than 5 years old so certainly even if I buy a cheap computer today it'll probably have 4x the RAM anyway.

2

u/puddingcrusher Feb 28 '16

Precisely. We work in a field where every decision has trade-offs, and it's great so see when all variations are implemented well, because there is always a use-case to be found.

It's the same thing as with programming languages: None are perfect, but even the worst have a specific use case where they outshine everything else.

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

2

u/[deleted] Feb 27 '16 edited Feb 27 '16

with static linking we're talking more than 500mb wasted. It could actually get worse than this with larger libraries and multiple libraries.

i don't think space is really an issue anymore on the desktop. on windows it's the same thing, apps are the size you mention. the point is now that vendors might have it easier now distributing binaries for linux at the cost of binary size.

anyway, i'm happy with my dynamically linked library, it makes more sense to me. although i can understand that people are trying to make this a thing to get more software available for linux.

to be fair the other comment in this thread sounds great though: https://www.reddit.com/r/programming/comments/47ufrt/appimage_linux_apps_that_run_anywhere/d0fug8o

→ More replies (17)