Yes. guns were considered old school an they had only missiles so when they were expended, those planes were just more targets for the MiGs. I believe a number were lost that way and so the retro fit.
I do believe that a fighter aircraft SHOULD have an onboard, built in gun. It is a poor tactical decision to have to use it, but to be in a situation where you need one and don’t have it is even worse.