The vast difference in size and strength would surely result in them being killed?
Or perhaps swordsmanship would balance out the fight?
What was really expected of these young boys when it came to close quarter fighting?
The short answer is that yes, children served on board Royal Navy vessels and were sometimes expected to fight, in various capacities. However, it should be noted that the action in the film was one of very extreme straits, and the difference in the size of the enemy ship and enemy crew necessitated the use of every man available - you'll note that even the surgeon went over with the boarding party.
However adventurous, the depiction is loosely based on a real action, after it jumped through a few hoops. The action of the Surprise against the Acheron in the film was itself a transplant of the action of the Sophie against the Cacafuego taken from Patrick O'Brian's first novel of the Aubrey-Maturin series. That action was taken, nearly shot for shot, from the real action of the Speedy, under commander Thomas Cochrane, against the Spanish Xebec frigate El Gamo.
This was a particularly and justifiably famous action, as the Speedy was totally outclassed, being a small brig-rigged "sloop of war" possessing an armament of fourteen 4 pounder cannons, which Cochrane charmingly called "popguns," and at the time of the action with the Gamo, a crew of 54. The vessel was so small that "my only practicable mode of shaving consisted in removing the skylight and putting my head through to make a toilet-table of the quarterdeck."
El Gamo was a much larger vessel, carrying twenty two 12 pounders, eight 8 pounders, and two 24 pound carronades, and a crew of more than 300 men. In the action it was found that at the range at which Cochrane's false-color ruse (similar to what was done in the film) was done away with, the Gamo's fire went over the tiny vessel, doing damage to the rigging but little to the hull or crew. After firing broadsides, getting close enough for the Spanish to attempt to board, and then shearing off to fire volleys of small-arms and swivel-gun fire to the Spanish crew, "after the lapse of an hour the loss to the Speedy was only two men killed and four wounded."
Cochrane then ordered his men to board the frigate, every man of the crew with the exception of the ship's surgeon, Mr. Guthrie, who took the helm of the Speedy. Every man and officer would have meant at least one midshipman. In the novel, Patrick O'Brian had the fictional William Babbington serve the Sophie, but the names of any of the young gentlemen on board the Speedy is not something I've been able to find. In the film, of course, the casualties are much higher than in either the fictional Sophie's or the historical Speedy's, with the young gentleman Calamy being killed, along with several officers and men.
Note, once again, the extreme nature of this action: the Speedy was outclassed, outgunned, and outmanned, and it's likely that we look at it as an example of British naval dominance instead of reckless misadventure because Cochrane succeeded against all odds. While midshipmen were officers, and thus subject to all the same cultural elements I've discussed before about gentlemen and the military vocation in the period, they could also vary quite a bit in age and experience, and a captain would take that into account before ordering a 12 year old boy to lead a boarding party. But midshipmen were expected to lead in combat, officering boats, commanding guns or topmen, and serving the ship in carious capacities while under fire. There was nothing much more dangerous in a boarding action than there would be in manning a gun against an enemy broadside or leading a boat in a cutting-out expedition. If necessary, they would do it, even if it was dangerous.
I hope another commenter may give an even deeper treatment of the life of midshipmen on a ship of war, but as my expertise lies more on the land side of things I'll stop here.
All quotes from Cochrane come from Every Man Will Do His Duty by Dean King. You may also like to read Nelson's Navy by Brian Lavery.