Patents protect the idea of a particular program. And in the post-AI world, it's the idea that holds the value, not the implementation. Implementations are cheap now.
Another alternative to preventing the entire software market from collapsing is to revive the Whelan v. Jaslow copyright standard, under which the abstract "structure, sequence, and organization" of a program is eligible for copyright. But programmers would bristle at that almost as much as robust patent protection for software. Until, that is, the money comes in with mouths to feed and mortgages to pay...