You have six axes of motion. 3 linear dimensions, X, Y and Z, and three rotational components around the axes of X, Y and Z.
Effectively, and more simply mathematically, KE1=KE2
KE = kinetic energy = 1/2mv^2
KE1=gun
KE2=bullet
Fast bullet, slow gun because guns weigh more. Less gun mass, less recoil, that simple.
When you get into elaborate physics calcs, we talk about all six of these axes simultaneously, which is all the energy components that make up the recoil. We have to assume the bullet left the barrel. Not entirely true, but we're talking milliseconds, so not an issue. All that energy is imparted back to the user of said firearm.
This recoil is largely determined by the form factor of the firearm.
How far is the axis of the bullet above the grip?
What's the form factor. Moment of interia in x,y,z axes.
What's the muzzle twist of the barrel?
What's the bullet mass?
It all comes into play. This is why small 9mm mouse can whomp you more than and weighty range magnum.