Guns, mechanically speaking, were always kind of an alien species to me. Unlike cars, there are not very many parts, the parts seldom wear out, and I don't think I've ever seen a hexagonal nut used in one.
Then there are the parts themselves. Very complicated shapes, very difficult to machine. Parts for automobile engines are simplicity itself, relatively speaking. Clamp the engine block in a milling machine, bore the cylinders, mill the top surface flat, drill and tap the holes for the head bolts: boom, boom, boom.
Or maybe I just never spent any time studying the intricacies of gun machining. If I look closely, I can see how it could be done, but geez, what a lot of tedious, small, detailed steps. Clamp it like this, use this kind of a tool, cut a groove from here to here (and no further!), at just this depth, just this width, and just this position. Now repeat for the 37 other little grooves and notches. OK, now you are done with the first part and you can go on to the dozen or so other, equally complicated parts that go into a gun.
Then there's the little parts. This one has always been a bit of stinker. How do you clamp something that small and delicate hard enough that you can mill it? Sometimes I think the answer is to mill it out of the edge of a larger piece, and then cut it off. It has to be right, because once you've cut it off, you are done with machining. You might be able to file it a bit, but that is only good for a few thousandths of an inch.
Lastly, there's the barrel. Pistol barrels aren't too bad, they are only a few inches long, but rifle barrels, they are measured in feet. How do you drill a straight hole through two feet of solid steel? One might think it is a straight forward proposition: clamp the barrel in a big drill press, put a long bit in the chuck and drill away. In a perfect world, with perfect steel and a perfect drill bit, that might work, but we all know this isn't a perfect world. Even a very good grade of steel can have minor inconsistencies. Drill bits these days are indistinguishable from perfect. The drill bit is going to wander. You start at the center of one end of the barrel and by the time it gets to the other end it could be coming out near the edge.
Someone must have figured out the trick, because the world has made millions of rifles. This has been bugging me for years. I looked for this information a while back (a few years?), but found nothing. This time I got some answers. Is it because the internet is expanding? Or it because this time I was holding my mouth right (and the search phrase I used happened to work)?
Wikipedia has a short explanation, Lilja Precision Rifle Barrels has a longer one, but the authority is the Machinery's Reference Series #25 published in 1910. In other words, somebody figured out how to drill gun barrels a hundred years ago.
Gun design is a whole other issue. The basic requirements are pretty straight forward: barrel, breech block and locking mechanism, but the details of how they are implemented are sometimes a mystery.
Take any gun apart and you can see how it works, but start examining how all the pieces fit together and trying to figure out what function each little groove and notch serves can be baffling. Sometimes there does not appear to be any point at all. Sometimes the mechanism appears to overly complicated for the apparently simple task it is meant to serve. I suspect that sometimes it is, but it might just as well be a case of "this complicated design" functions reliably, where the simpler design we used earlier did not, and that is something you only find out when you are around for the failures.
Guns are really pretty amazing devices. The basics were pretty much all figured out a hundred years ago (insert mention of the Holy Prophet of Gun Design: John Moses Browning and his self-adopted granddaughter, Tam*). The .45 caliber and 9mm handgun and the 30-06 and 50 caliber BMG all came into existence about then, and are still with us today. Everything that has been done in gun design since then has been minor variations, subtle refinements and experimentation.
Smokeless powder is what gave rise to modern firearms. It produces pressures never before encountered and so opened up a whole new area of technical challenges, which gave rise to some bizarre details found in gun designs.
* thanks to Roberta X for that phrase.
2 hours ago