The Journey of a Program
August 25, 2023
A lot happens when we move a program from one machine to another
Here's an outline of what I'm thinking about:
- Your program has an environment as soon as you write the first line of code.
- You may have thought very little about this yourself, or a lot. (Probably you're too busy thinking about how your program should work and to make it work to spend too much time on this now.)
- We tend to set up tools and resources once, at the begining, or maybe very occasionally as we go along
- We tend to not pay attention to these momemnts, forgetting that we'll need to repeat them on other machines or find suitable substitutes
- This is where the philosophy of "make development as much like production as possible" comes from: At a bare minimum you'll have found solutions to various issues you encounter and might be able to use them verbatim.
- Your program will be installed on a computer.
- The computer you install your program onto will already have:
- a directory structure
- a bunch of prgrams
- a bunch of security rules, like users and groups and file permissions and maybe some Seecure Linux (SELinux) rules.
- We refer to all of the above as "the environment"
- Your program has needs!
- A computer it can run on
- Compatable hardware architecture (arm, i86_64, etc.)
- Compatable operating system
- A place to live (locations in the file system) and enough room (storage space)
- Permission to run
- Maybe also a runtime (Java Virtual Machine, PHP interpreter), access to directories, or external programs (ls, mkdir), or network (ports like 80 for http), or even other programs (like systemd or httpd) or other computers (database)
- We refer to all of the above as "a compatable environment"
- Your program is going on a trip. What kind of destination?
- Luxury resort: No need to pack a bed! I can buy a toothbrush if I don't pack mine. Your exposure to the world is limited by design.
- Camping: Better bring it myself. You are exposing yourself to the world, you have a lot more to worry about.
- Some exmples:
- application framework: Laravel, Ruby on Rails, AWS Lamdbda, etc.
- web server public folder with configured runtime: (PHP, Java Servlets)
- Linux Container (Docker); Virtual Machine (AWS Firecracker?)
- directories in
/usr/local/
(binaries) - directories and tools (i.e. the c compiler)
- physical machine, virtual machine (self-hosting, data center hosting, AWS EC2 instance)
- How will your program get to it's destination?
- Distro Package manager (yum, dnf, Mac App Store, nixos, gentoo)
- Alternate package manager (MacPorts, HomeBrew)
- binary
- tarball, zip
- Aside: The System Administrator: The caretaker of your destination environment
- if you're self-hosting, they might be more like a park ranger. "Here's a map with water sources marked." (You'll have to do a lot of basic things yourself.)
- if you're in a web directory, they might be more like a resort director: "No you can't go into the kitchen to get your own drink." (Even though you can easily do it yourself.)