Physics of firearms. From the viewpoint of physics (dynamics, to be exact), a firearm, as for most weapons, is a system for delivering maximum destructive energy to the target with minimum delivery of energy on the shooter. The momentum delivered to the target, however, cannot be any more than that (due to recoil) on the shooter. This is due to conservation of momentum, which dictates that the momentum imparted to the bullet is equal and opposite to that imparted to the gun-shooter system.

Firearm energy efficiency 
From a thermodynamic point of view, a firearm is a special type of piston engine, or in general heat engine where the bullet has a function of a piston. The energy conversion efficiency of a firearm strongly depends on its construction, especially on its caliber and barrel length. 
However, for illustration, here is the energy balance of a typical small firearm for .300 Hawk ammunition:
Barrel friction 2%
Projectile motion 32%
Hot gases 34%
Barrel heat 30%
Unburned propellant 1%.
which is comparable with a typical piston engine.

Higher efficiency can be achieved in longer barrel firearms because they have better volume ratio. However, the efficiency gain is less than corresponding to the volume ratio, because the expansion is not truly adiabatic and burnt gas becomes cold faster because of exchange of heat with the barrel. Large firearms (such as cannons) achieve smaller barrel-heating loss because they have better volume-to-surface ratio.
High barrel diameter is also helpful because lower barrel friction is induced by sealing compared to the accelerating force. The force is proportional to the square of the barrel diameter while sealing needs are proportional to the perimeter by the same pressure.

Force
According to Newtonian mechanics, if the gun and shooter are at rest initially, the force on the bullet will be equal to that on the gun-shooter. This is due to Newton's third law of motion (For every action, there is an equal and opposite reaction).  Consider a system where the gun and shooter have a combined mass g and the bullet has a mass b. When the gun is fired, the two masses move away from one another with velocities g and b respectively. But the law of conservation of momentum states that the magnitudes of their momenta must be equal, and as momentum is a vector quantity and their directions are opposite:  
 

In technical mathematical terms, the derivative of momentum with respect to time is force, which implies the force on the bullet will equal the force on the gun, and the momentum of the bullet/shooter can be derived via integrating the force-time function of the bullet or shooter. This is mathematically written as follows:

 
Where  represent the gun, bullet, time, mass, velocity and force respectively.

Hollywood depictions of firearm victims being thrown through plate-glass windows are inaccurate. Were this the case, the shooter would also be thrown backwards, experiencing an even greater change in momentum in the opposite direction. Gunshot victims frequently fall or collapse when shot; this is less a result of the momentum of the bullet pushing them over, but is primarily caused by physical damage or psychological effects, perhaps combined with being off balance. This is not the case if the victim is hit by heavier projectiles such as 20 mm cannon shell, where the momentum effects can be enormous; this is why very few such weapons can be fired without being mounted on a weapons platform or involve a recoilless system (e.g. a recoilless rifle).

Example:
A .44 Remington Magnum with a  jacketed bullet is fired at  at a  target. What velocity is imparted to the target (assume the bullet remains embedded in the target and thus practically loses all its velocity)?

Let  and  stand for the mass and velocity of the bullet, the latter just before hitting the target, and let  and  stand for the mass and velocity of the target after being hit.
Conservation of momentum requires
 = .
Solving for the target's velocity gives
 =  /  = 0.016 kg × 360 m/s / 77 kg = 0.07 m/s = 0.17 mph.

This shows the target, with its great mass, barely moves at all. This is despite ignoring drag forces, which would in reality cause the bullet to lose energy and momentum in flight.

Velocity
From Eq. 1 we can write for the velocity of the gun/shooter: V = mv/M. This shows that despite the high velocity of the bullet, the small bullet-mass to shooter-mass ratio results in a low recoil velocity (V) although the force and momentum are equal.

Kinetic energy
However, the smaller mass of the bullet, compared to that of the gun-shooter system, allows significantly more kinetic energy to be imparted to the bullet than to the shooter. The kinetic energy for the two systems are  for the gun-shooter system and  for the bullet. The energy imparted to the shooter can then be written as:

For the ratio of these energies we have:

The ratio of the kinetic energies is the same as the ratio of the masses (and is independent of velocity). Since the mass of the bullet is much less than that of the shooter there is more kinetic energy transferred to the bullet than to the shooter. Once discharged from the weapon, the bullet's energy decays throughout its flight, until the remainder is dissipated by colliding with a target (e.g. deforming the bullet and target).

Transfer of energy
When the bullet strikes, its high velocity and small frontal cross-section means that it will exert highly focused stresses in any object it hits. This usually results in it penetrating any softer material, such as flesh. The energy is then dissipated along the wound channel formed by the passage of the bullet. See terminal ballistics for a fuller discussion of these effects.

Bulletproof vests work by dissipating the bullet's energy in another way; the vest's material, usually Aramid (Kevlar or Twaron), works by presenting a series of material layers which catch the bullet and spread its imparted force over a larger area, hopefully bringing it to a stop before it can penetrate into the body behind the vest. While the vest can prevent a bullet from penetrating, the wearer will still be affected by the momentum of the bullet, which can produce contusions.

See also
Ballistics
Internal ballistics
External ballistics
Table of handgun and rifle cartridges

References

Firearms
Applied and interdisciplinary physics
Classical mechanics

de:Innenballistik