The short answer
It depends how their packaged and if the language is interpreted or compiled.
The long answer
Interpreted apps run anywhere their interpreter runs. They use human readable syntax (commonly referred to as scripts) to describe to another program that knows how to work with the enviroment what to do. Programs like bashtop and bpytop are examples that’ll run anywhere BASH or Python are installed. The programs may ask the interpreter to do things that only work on Linux or specific OS’s though but they’re usually cross-compatible if they’re designed for Linux.
Self-contained apps come with everything they need to run and the dominant forms are AppImage, Flatpak and Snap. They’ll work on any distro that have the dependencies installed to run those formats and all mainstream distros will either have those pre-installed or available in their repos.
- AppImages need
fuse
- Flatpaks need
flatpak
- Snaps need
snapd
Some repos may name these differently like fuse
may be called fuse3
.
Compiled apps are usually written in C, C++, Rust, Go, ect and need to be compiled against the specific environment they’ll be running in using GCC, MUSCL, ect. You can compile and install these manually but what’s so amazing about mainstream distros is they do that for you by way of their repos and package managers like apt
, dnf
, yum
, ect.
They’re compiled against different environments and placed in the appropriate repos including dependency information for easy installation. As long as a distro is environmentally similar enough to what the app was compiled against it can be installed as easy as sudo apt install cowsay
. There’s also PPAs which work in a similar way and Arch has the AUR which is a community run extension of the Arch repos.
What that means is distros like Linux Mint can rely heavily on Ubuntu’s software repos because it’s basically a copy of Ubuntu under the hood but Arch, Fedora, SUSE, ect can’t because they differ too much, their repos depend on apps being compiled against their environments and not every repo has someone compiling every app.
The short long answer
Scripts and self-contained apps (AppImage, Flatpak and Snap) will run generally everywhere as long as you install the basic dependencies.
Pre-compiled apps (ex: sudo apt install krita
) are distro specific and may not be available everywhere. Arch users often use the AUR (a community repo) to improve availability of pre-compiled apps.