Well, from where I know, the main diferences are economic and strategic.
The economic diferences are:
-Spears are cheaper to produce and maintain (less iron, the shaft can be replaced easly)
-Spearmen are easier to train, hold the pointy end aiming to the bad guys and poke when you find an open spot, and preety much it. While swordsmen need more than that, since they have more striking options.
The strategic diferences are:
-The spear is the best weapon when you have big numbers, like Quintus said, since the guys on the second and third row now become a threat. (this is why they counter cavalry, a horse ocupys more space, increasing the number of enemies per soldier even more).
-This, however, requires a well coordinated formation since individualy they lack the striking options that a slashing weapon would, wich makes them rather predictable and easily beaten.
-Thus, this means that swordsmen have the versatility to remain efective in not so coordinated formations. And when this formations take place? After charging. Swordsmen have much more freedom when performing a charge than Spearmen would. And since individualy can fend off better, this makes disengages also less risky.
-Its easier for swordsmen to carry more/heavier javelins since they can hang their weapon in their belts. Spearmen cant afford this luxury.
So, as a conclusion. In practice, Spearmen are the less mobile, denser troops that are more capable of holding the line defensively. They cant charge, nor retreat, only hold the line and advance slowly. On the other hand, Swordsmen act as shock infantry, not needing to keep a perfect formation, runnin to specific points of the battle to deliver a solid punch to the enemy flank and pulling back before they turn their spears on them, leaving a serious dent.
Bookmarks