mid-14c., gunne "an engine of war that throws rocks, arrows or other missiles from a tube by the force of explosive powder or other substance," apparently a shortening of woman's name Gunilda, found in Middle English gonnilde "cannon" and in an Anglo-Latin reference to a specific gun from a 1330 munitions inventory of Windsor Castle ("... una magna balista de cornu quae Domina Gunilda ..."). Also compare gonnilde gnoste "spark or flame used to fire a cannon" (early 14c.).
The identification of women with powerful weapons is common historically (such as Big Bertha, Brown Bess, Mons Meg, etc.).
Or perhaps gun is directly from Old Norse gunnr "battle." The word was perhaps influenced by or confirmed by (or possibly from) Old French engon, dialectal variant of engin "engine."
Meaning grew with technology, from cannons to firearms as they developed 15c.; popularly applied to pistols and revolvers from 1744. In modern military use the word is restricted to cannons (which must be mounted), especially long ones used for high velocity and long trajectory. Hence great guns (1884 as an exclamation) distinguished from small guns (such as muskets) from c. 1400. Meaning "thief, rascal" is from 1858. For son of a gun, see son. To jump the gun (1912, American English) is a figurative use from track and field. Guns "a woman's breasts" (especially if prominent) attested by 2006.
[G]un covers firearms from the heaviest naval or siege guns (but in technical use excluding mortars and howitzers) to the soldier's rifle or the sportsman's shotgun, and in current U.S. use even the gangster's revolver. In the other European languages there is no such comprehensive word, but different terms for the small or hand gun of the soldier or sportsman (even these, sometimes differentiated) and the heavy naval guns or artillery pieces .... [Buck, 1949]
"a gun which by means of a mechanism delivers a continuous fire of projectiles," 1870, from machine (n.) + gun (n.). As a verb, "to shoot down or kill by means of a machine gun," it is attested by 1915. Related: Machine-gunned; machine-gunning; machine-gunner.
A man is entitled to the fruits of his labor, and to assert a just claim is a duty as well as a right. In the year 1861 I first conceived the idea of a machine gun, which has been ever since the great controlling idea of my life; and it certainly cannot be regarded as egotism when I express the belief that I am the originator of the first successful weapon of the kind ever invented. [R.J. Gatling, quoted in Scientific American, Oct. 15, 1870]
Though in the light of subsequent advancements Gatling's invention of 1862 is not considered a modern machine-gun.
1864, named for its designer, U.S. inventor Richard Jordan Gatling (1818-1903); patented by 1862 but not used in American Civil War until the Petersburg campaign of June 1864 as an independent initiative by U.S. Gen. Ben Butler.
For the first time in this war, the Gatling gun was used by Butler in repelling one of Beauregard's midnight attacks. Dispatches state that it was very destructive, and rebel prisoners were very curious to know whether it was loaded all night and fired all day. [Scientific American, June 18, 1864]