"your code is a trade secret protected via contracts" isn't enough to replace copyright because the contracts are only enforceable to the signing parties.
Let's say you write some software for your employer and they sell the product to several customers with a contract not to distribute it. However, the product appears on some pirate website anyway, and you can't identify who allowed the product to be leaked. Once it's there, your contracts are worthless as nobody who downloads it from the pirate site will be bound by your contract. You need copyright laws to prevent subsequent distribution.
Without copyright laws, you'd then end up in the situation where people who paid for the software then are bound by the contract and would have to keep paying, and those who just downloaded it from a pirate site would be completely fine legally and could use the software with impunity. That would create a disincentive for anybody agreeing to buy the software and entering into a contract in the first place, essentially killing the industry.
You might not see a problem with that if you believe in Open Source, but most licences require copyright laws to exist to protect the software freedoms so that people don't just take the software and close source it.
Yeah, I'm assuming most people here aren't selling proprietary code to customers directly. I assume most professionals here work somewhere that sells SaaS or uses the software they develop internally only.
If I recall correctly most software work goes to custom software. Note that in many, possibly most, cases, the (sole) customer retains the exclusive rights to the source code, making the software effectively Free per the FSF definition (because the user is free).
Almost my entire career was spent on such custom software. The rest was internal software. And even that one I was doing as a contractor, so in a way we could argue it was custom software even there.
Even if they don't sell the code to the customers directly (or even binaries, because that's what most customers actually care about), somebody in the chain is selling that software to the end customer and that money is going up the chain. It's kind of obvious really - if the work you're doing isn't creating saleable value, then your company won't be able to pay you.
But there is far, far more in the world that just SaaS or internal only software. Sure, companies are generally shifting towards SaaS (in part because it allows them another way to combat piracy, but also to extract recurring revenue rather than one off purchases), but there's still plenty of software you can go out to the shop and buy. Most of that wouldn't exist without copyright laws, because those developers would have found some other way of making a living instead.
> somebody in the chain is selling that software to the end customer
Not necessarily? Any infra software is invisible to the end consumer. It's bundled into the price the customer pays for what they see, but they themselves don't know or care about the former.
> there's still plenty of software you can go out to the shop and buy
... is there? I haven't bought software in a shop in 20 years at least. Outside of games, I don't really buy software digitally, even. It's either FOSS or it's a subscription.
From the top of my head, the easiest examples are games. Where I live at least, there are still physical stores in most malls with loads of disc-based games for sale. But also, for instance, I can go into my local computer store and pick up a boxed copy of Windows, so yes physical software sales is definitely still a thing. I personally haven't done it for a long time, but I know it exists.
But anyway, the method of software delivery is tangential to the main point. Plenty of software exists that runs locally, regardless of how is paid for - whether subscription or one-off purchases, if it runs on your computer it relies on copyright law to protect the revenue stream for the developers. Without copyright laws, if one physical sale could be freely copied with impunity, sales would be vastly diminished to the point that many developers would just not bother and find a different industry to work in to earn a salary.
Let's say you write some software for your employer and they sell the product to several customers with a contract not to distribute it. However, the product appears on some pirate website anyway, and you can't identify who allowed the product to be leaked. Once it's there, your contracts are worthless as nobody who downloads it from the pirate site will be bound by your contract. You need copyright laws to prevent subsequent distribution.
Without copyright laws, you'd then end up in the situation where people who paid for the software then are bound by the contract and would have to keep paying, and those who just downloaded it from a pirate site would be completely fine legally and could use the software with impunity. That would create a disincentive for anybody agreeing to buy the software and entering into a contract in the first place, essentially killing the industry.
You might not see a problem with that if you believe in Open Source, but most licences require copyright laws to exist to protect the software freedoms so that people don't just take the software and close source it.