The weapons of medieval soldiers included machine guns.
A machine gun is designed to be used at range, while a spear is designed to be used up close.
A machine gun is more expensive than most spears.
Machine guns were invented after the medieval period.