This being Hacker News: The reason the digit 7 seems important here is that these are actually Octal. Under the hood this is a digital system, but the user interface is four octal digits ie 0000 to 7777 is a 12-bit value.
Most modern aircraft are capable of providing a lot more data over their radio transponder, including a system unique identifier, but it turns out that "squawking" a four digit code is a useful amount of discretion to give humans. If you could do it over maybe a decimal code would have been better, but too late now.
when you look at all the reserved blocks, that's not a lot of usable address space. the internet says there are roughly 5k commercial aircraft in the air above the us during peak times. i get that these are regionally allocated, but still pretty tight i must imagine.
do modern mode 3 transponders also include tail number or some other unique identifier in a sideband?
Yes, the squawk code is not itself necessarily used to identify individual airplanes and distinguish them from one another and transponders now transmit significant amounts of data on top of the squawk code.
(I don't know how much squawk codes are, or were, used to specifically identify aircraft in the past, but I believe that currently it's not unusual that many aircraft in the same region would be squawking the same number, which would not confuse ATC because of all the other transponder data that's available.)
This depends strongly on the region. The US still has a very old system in use for the center controllers which are the big regions. That system wants discrete codes for each aircraft in each area, so they make flights change code if there is overlap while flying into the next region.
In Europe some areas (but not all) have switched to using the Mode-s/ADS-B identification (which is a 24 bits unique code not configurable by the pilot but fixed to the aircraft) in their systems and setting the traditional transponder code to 1000 for all of those aircraft.
In the long term expect everyone to adopt that approach, but things in aviation move very slowly so it will be many many years before we're there.
Most modern aircraft are capable of providing a lot more data over their radio transponder, including a system unique identifier, but it turns out that "squawking" a four digit code is a useful amount of discretion to give humans. If you could do it over maybe a decimal code would have been better, but too late now.