A gun barrel is the tube, usually metal, through which a controlled explosion is released in order to propel a projectile out of the end at great speed.
The first guns were made in a time where metallurgy was not quite what it is today, so the pipe needed to be braced periodically along its length, producing an appearance somewhat reminiscent of a storage barrel.
Another explanation, tied to etymology, states that many very first firearms barrels were in fact realized, during the 12th and 13th centuries, using small storage barrels with their usual metal rings reinforced by leather, hence the barrel name. In fact a set of old French words, some of them staying in modern French, were used as root words for various English terms related to firearms (and storage barrels). The old French gonne (pronounced by a French speaker it sounds approximately as gun does when pronounced by an English speaker) was a small barrel used on merchant and military ships. Likewise a baril was, as early as 1323 (used in Du Chevalier au barisel), and remains now, a big barrel. Moreover the big Tun English barrel is, as stated in Ton, the French old and contemporary tonne barrel.
Modern day gun barrels are sophisticated in their construction and makeup. A gun barrel must be able to hold in the expanding gas produced by the propellants to ensure that optimum muzzle velocity is attained by the bullet or shell as it is being pushed out by the expanding gas(es). Early firearms were mostly muzzle loading (loaded from the mouth rather than the breech), which tends to be a slow and complicated procedure, resulting in a low rate of fire. Breech loading provided a higher rate of fire, but early breech loading guns lacked an effective way of sealing the escaping gases that leaked from the back end of the barrel; resulting in a lower muzzle velocity. During the 19th century, effective mechanical locks were invented that allowed loading from the breech while effectively sealing the breech from escaping propellant gases.
Gun barrels are mostly of metal construction. The early Chinese, the inventors of gunpowder, used bamboo, a naturally tubular wood, as the first barrels in gunpowder projectile weapons. Early European guns were made of wrought iron, usually several bands of the metal arranged around circular wrought iron rings and then welded into a hollow cylinder. The Chinese were the first to master cheap cast-iron cannon barrels. Bronze and brass were favoured by gunsmiths, due to their ease of casting and their ability to resist the corrosion created by the combustion of gunpowder. Modern gun barrels are of nickel and steel alloys, which are made to withstand the tension created by the rapidly expanding gases of the cartridge as well as resist corrosion. As metallurgy advances, barrels can be made smaller and lighter without undermining their strength in holding the explosive gases as the firearm fires. Early cannons were hugely thick for the caliber that they fired. Early manufacturing defects (such as air bubbles trapped in the metal) were key factors in many gun explosions, when the expanding gases became too much for the weak barrel, causing it to rupture and explode in deadly fragments.
Generally the term "smallbore" refers to rifles or pistols whose barrel bore diameter is at the small end of the scale (.170" to .399"). Rifles, revolvers and semi-auto pistols in calibre .22 rimfire are popular all over the world for small game hunting and casual target shooting.
 See also