you are correct if you assume that all inventions will be made and become part of general knowledge in either case.
back when patents were invented there was a real problem with inventions being protected by 'trade secrets' and inventions being lost as the owner of the secret died. Patents 'solved' this problem by getting the person to reveal the details of the invention. This is why one of the requirements of a patent be that it give enough details that someone 'ordinarily skilled in the field' can implement the invention.
unfortunately many patents nowdays (especially in software) do not provide such details, they are written to be so broad that nobody really knows what they cover.
The fact that the patent offices don't enforce this aspect of the patent goes hand in hand with the fact that they can't seem to evaluate if the patent would be obvious to someone 'ordinarily skilled in the field'
if these restrictions were in force, then there would be far fewer problems with patents.
the issue of revealing the secret can apply even with software. If you look at things like encryption, it would be possible to have someone invent a super algorithm and patent it, ship a module to implement it, and even though people could reverse engineer the module and see _what_ it does, they would not be able to tell _why_ it does it (are the numbers the module uses ones that are special in some way? or are they just random numbers that were picked? how would you find another value that's special in the same way?....)