"Also, check the guarantee on media, I think you'll find that it only covers the media, not the content. If it's faulty then they only have to replace it with blank media. Technically you've paid for blank media. How does that make you feel?"
I have no idea where you get that idea from. Defective prerecorded media is replaced with another, non-defective, copy of the same content. As an example that I know personally: In the 1990s, Philips DuPont Optical (UK) produced tens of thousands of defective CDs that would degrade badly over time. Customers with such discs (I had about seven) were able to exchange them for re-pressed, correctly functioning ones. And, as you asked, I felt fine about it.
"What you see happening in the real world is people (like programmers) who create stuff all day every day, but don't get paid every time their work is sold on, they get paid while they're actively creating stuff."
And... where does the money come from to pay them? For a software system, there may be cost savings (i.e., increased profits on the same level of sales) to pay for it later. For a creative arts work, though, where does the money come from? The commissioner needs to be able to sell the work to cover the costs. But if the commissioners don't achieve a return from using, exhibiting or reselling the work, then the fees for artists drop. The royalty model, incidentally, is also to protect the publisher from the up-front cost of funding a work that might not have any success, and it's not unknown in IT either (I know people who've set up e-commerce systems in exchange for a percentage of takings, and it's how the global credit card clearing applications and most Software-as-a-Service operations are funded too), and not all creative work is done on royalty: there's a lot of flat-fee work in writing and graphic design, for instance. Conversely, I have several friends who sell software on royalty: anyone who sells their own work in the various App Stores is selling on royalty; I've done it myself, and I know of people who have done revenue share (a form of royalty) in lieu of upfront payment.
You mention session musicians, but by definition they're not creators, and are normally paid hourly, and on a flat-fee basis. Copyright is not an issue for session musicians, because they're playing someone else's work: It's the people who invented the music they play that are relying on copyright to protect their livelihood (there is overap between these groups, but not always). When it comes down to it, there's not much difference between a software developer and composer, filmmaker or author: all start with the knowledge in their head and create something from it that didn't exist before. It's not the "idea" you're asked to pay for; anyone can have an idea. It's the effort to bring that idea into some form of working reality, be it a symphony, application, novel, design or film.
"So, presumably if I did that for an agreed fee and you then sold my work to other people who need a new network infrastructure or CRM system, you would pay me a royalty on every sale?"
Not unless you'd agreed this. You would have got to negotiate re-distribution as part of the contract you signed before working. In most cases, a software development contract is effectively a flat-fee creative commission.
Normally I, as the commissioner, would be able to re-sell the work you've given me, unless otherwise negotiated, but that's because you assign copyright to me as part of the contract. I don't recall Google/YouTube or any of the filesharers being given any rights over works by the authors of those works. They just "find" them lying around and make money from them without paying the dues.
I don't support the removal of fair use provisions (which include satire, incidentally), but the idea that Google are really only fighting to uphold these rights is laughable. We wouldn't be in the situation of losing these if Google hadn't been playing fast and loose with copyright on an industrial scale with YouTube, and also turning a blind eye to the wholesale piracy that it makes financially viable (count the number of Google Ads you see next time you go to a download site).