Despite the historical interchangeability of these two terms, they indicate different things. These are both ways to control the movement of data in memory to another storage device called backup storage (often a hard drive), but they use different methods to do this.
Swapping involves moving the process of collecting entire in-memory data to a space area in the backup storage, often to a swap file or swap. The process goes from being in memory completely replaced; between them no. Obviously, the process must be completely inactive for the exchange to be generally worthwhile. The advantage of this is that it is relatively easy to understand, and the memory for the program is always allocated contiguously, and the disadvantage is that the performance on the machine can become absolutely terrible when the system gets into a state where things are constantly changing. The algorithm also includes replacing data that will not be used for the foreseeable future.
Paging tries to solve this problem by taking physical memory and cutting it into things called “frames” of a certain fixed size. It also occupies the memory space of each running process and cuts it into pages (the size of which is equal to frames); this is called a physical address space, due to the need to use physical addresses to access each memory block.
Each program is an OS environment and is supported by modern equipment, which makes the program memory space similar to a single continuous block with a very large amount of memory; this is called a logical address space.
However, each page of this adjacent block may be in memory or may be in the backup storage. The operating system determines where each page is located, with reference to what is called a “page table”. If he finds the page requested by the program somewhere in memory, it simply goes to this memory page and captures the requested data.
If he finds that the page is not in memory; this causes a "page error". The OS pauses the process while it loads the requested page from the backup storage and, in turn, can move another page from memory to the backup storage to free up space based on some replacement algorithm. The support repository can be called a swap file or it can still be called a swapfile or swap file, which leads to confusion as to which system is used. Regardless of whether it is a separate partition or just a file, it depends on the operating system.
There are certain parts of memory that cannot be unloaded. One of them is the paging code itself and parts of the kernel that handle things like page errors. Some operating systems, such as MacOS, refer to this memory as “wired”.
Modern hardware has several devices that allow the operating system to support paging much more efficiently. The most common of these are translation buffers or TLBs. It stores some cache of the hardware page table, so whenever a program needs to make a logical address to translate a physical address, it does not need to ask the operating system each time.
Modern operating systems also use paging with lazily loaded parts of the processes in which they operate. For example, if you run Microsoft Word, instead of loading the entire program into memory, the operating system will instead load only those parts of the program that it needs into memory and capture other parts of the program only as necessary. This has trade-offs, as well as between memory size, download speed, and how often delays occur in the program, since new parts need to be loaded.
In any case, maybe more than what you are looking for, but hopefully interesting.