I like to use the light_spear attribute instead the spear, the melee penalty is much smaller or even non existent, but the spearmen still get some protection against frontal cavalry charges.