To begin, we must first acknowledge the difference between "artillery" and "engines of war." It is more than just a matter of scale and distance - it must also be taken into account that artillery lobs complex shells that are capable of doing more than merely blunting an enemy fortification. Artillery creates fire, it creates shrapnel ... and most importantly of all, it creates smoke. Engines of war are a complex arrangement of mechanical applications; artillery is a much more systematized weapon, applying scientific methods that require physics as well as geometry in order to promote accuracy.
D&D weapons, even magic, rely almost entirely upon line of sight, which with weapons includes a near-flat trajectory (direct fire), and with magic means a perfectly flat trajectory (almost anti-physical in nature). While long bows employed at Crecy and Agincourt clearly were not fired to produce a flat trajectory, but were mass fired blind at opponents beyond friendly lines, there are no rules for the in D&D that I know of. Ask your DM - what's your chance of pulling twenty bowmen together and then having an effective attack by firing blind into the goblin's fortification? Don't expect the DM to assign a 5% chance per bowman.
Artillery is entirely about indirect fire, produced with frightening accuracy. Airburst artillery, in which the shell explodes above the ground and fires shrapnel into every possible axis, is so deadly in fact that most military situations would prefer not to use it (as it tends to kill defenders and attackers indescriminately). It is something like a mechanical fireball ... except that someone can load the gun again and produce the same effect about 90 seconds later.
Artillery can also lay groundsmoke so that it covers the battlefield, making the blind indirect method of artillery use more effective by reducing direct fire attacks. This is why they say, on the battlefield, artillery is king.
The cannon precedes the modern artillery piece, and is the first frustration for a game that wants to include "gunpowder" but not "modern warfare." See, the trouble is that cannons produce modern warfare by blasting holes in everything and forcing towns to reproduce themselves as large, flat geometric shapes, as early as the 16th century. Battle ceases to be the sort of thing that you see in ancient Rome, and starts to be a ridiculous free for all in which humans are cut to pieces because they happen to be standing in the wrong spot (there were cannons at Crecy and Agincourt too, though we tend to forget that). Being slaughtered as twenty cannon balls filled with shot and gunpowder explode randomly next to the party tends to ruin the whole joy of battle, so many campaigns say 'yes' to gunpowder pistols, while casually forgoing their cannon grandfathers. But many campaigns also avoid mass struggles in general, so it works out.
Funny thing about cannon and direct fire. They aren't. Cannonballs do not fly straight (thought it was assumed that they would), and for a time (more than a century) it was tremendously frustrating to aim them. It was not merely enough to raise or lower the cannon, or shift it left or right ... the balls themselves were made of stone or partial iron or whatever large block could be stuffed into the breech, and as such one cannon "ball" did not fly exactly like another. Even small imperfections would mean missing at a distance of a hundred yards, as any major leaguer can tell you about a baseball over 90 feet.
This problem launched considerable scientific inquiry into ballistics, air resistance, mass displacement and so on ... but James Burke can catch you up on all that (for the short jump up, watch from 13:00 to 19:00).
Which brings me up to the usual question about magic and history. One can easily say, well the problems of understanding missiles curving through the air can be solved with magic. Yes, that's true ... if the magicians are aware that missiles curve through air. We did not fully understand that they did, or how they did, in history until after 1500 (Tartaglia's date of birth - see link). So why would mages in the 11th century not automatically assume that objects did as Aristotle said they did? Would not magic - for a couple of centuries at least - frustrate itself trying to force cannonballs to fly straight, until it became evident that non-magicians were wreaking bloody havoc by simply allowing them to fly in a curved fashion, thus employing artillery far better than the magician's could?
Is this not the sort of thing that would have been happening continuously? We can't assume that magicians always knew the truth about natural physics going back four or five thousand years. We MUST assume that they were ignorant of quite a number of physical principles, which had yet to be discovered by Aristotle or Al-hazam or Tartaglia. Which would mean that for a time, magic was designed to compensate for our inability to do this particular thing, which was then later understood, forcing magic - like any other technology - to adapt itself and change. Which would mean there were spells that had been created for the purpose of making a two crowns of different metals displace the exact same amount of water, even though they were technically of different volumes.
Perhaps it was Aristotle himself who invented the spell ... and thus blew understanding the physical principal. By constantly "fixing" inconsistencies in physics, magic might possibly have increased the general ignorance of the upper classes, so that it would really be a fighter type or a monk, and NOT a spellcaster, who solved these things despite magic's insistence to the contrary.
Magic might have made us all dumber.