If you want to enjoy even more pain, ah trivia I mean, NXOS and NXOS are not the same thing. Read it again. There is an NXOS train for the original 2/5/7K and current kit in that line, and there is another version for the 3/9K new kit from the ACI spin in. They are just different enough that it makes things difficult when you are trying to develop tools for them. Cisco has promised to merge the two for a long time now.
IOS-XE is essentially IOS Classic running as an application on top of Linux, communicating with the actual forwarding hardware. NX-OS is similar but without legacy of having been a standalone OS. Linux generally stays away from all networking work and just provides a nicer deployment target with nicer APIs than bare bones MIPS/PPC/x86
A switch operating system doesn't do the actual networking stuff, all that happens in the switching ASIC. All the OS does is apply configurations and basic management tasks.
If it runs on a $10 raspberry pi it will run fine on a $20,000 switch.
Well, that's not really the case with higher-scale router operating systems like IOS-XR. You have a ton of protocols running in software, so performance and memory requirements increase quite a bit.
And then there are the high-availability (HA) requirements which typically lead to redundancy in software and hardware.
> Linux seems like it would be a bit heavy for a switch
Linux (and other Unix or Unix-like) kernels (and indeed full OS distributions) run fine on many low-end and embedded CPUs and hardware, and network switches are no exception.
OpenWRT is Linux-based and runs on extremely low-end switches such as home routers and access points.
Arista EOS is based on Fedora. (Of course Arista switches have real server CPUs and lots of memory. People do crazy things like running KVM on them.)
Juniper's Junos is based on BSD.
Remember that on a high-speed switch packets usually pass through the switching hardware without touching the switch CPU. Programmable switching chips like Tofino typically run pre-compiled pipelines that execute on-chip at line rate. The switch OS is primarily used for running management software that programs the hardware, runs the CLI, and/or provides other services. The OS can also run software to provide higher-level protocols and services such as BGP, DNS, or DHCP.
Eh, it's probably not that bad. On the low end, Linux isn't a slouch with XDP, etc. On the high end, it's game over if your kernel is in the data plane at all anyway, and Linux is a great option for the control plane of a switch.
SONIC is less mature but it's free and open source with the benefits and drawbacks that entails. For example, SONIC runs on a variety of different hardware so you could take advantage of that diversity without having to learn different NOSes.
Ten years ago switches were using 800 MHz single-core PowerPCs which was adequate to run Linux (although many were using VxWorks or whatever). Now the $400 switches are still wimpy but more expensive "disaggregated" switches are using Atoms or low-end Xeons.
https://en.m.wikipedia.org/wiki/Cisco_IOS_XE
https://en.m.wikipedia.org/wiki/Cisco_NX-OS