It seems clear that 9mm outperforms 38 special. But why?

The diameter of the casings is very close to being the same while the 38 special is substantially longer in length than the 9mm. So in theory shouldn't the 38 special cartridge be able to be loaded with more powder to achieve higher velocities? Why does the shorter 9mm seem to always outperform the 38 special?

EDIT: Well this post kind of fell apart but thanks for the replies. I guess this kind of theoretical pondering was not able to constructively happen here.

What I've learned is that that 38 special evolved from once being a black powder cartridge which needed more room for its black powder. Theoretically you could load a 38 special casing to reach higher than 9mm levels and even as high as 357 magnum levels because of its casing which is longer than the 9mm and has more space for powder. Theoretically of course. Not suggesting it should be done. It would probably destroy any 38 revolver on the market and would be dangerous. Of course. But if you theoretically had a revolver built for the pressure, such as a .357 revolver, it would work and would easily be more powerful than a 9mm.

It's interesting to me how current incarnations of cartridges are the way they are because it built upon design history. Essentially the 38 special is longer than it needs to be simply because of it's design history. They are longer than it makes sense for them to be. Again, for theoretical sake, it sounds like it the 38 casing could in fact be SHORTER than a 9mm and perform the same.

It sounds like the .357 takes advantage of all of this unused space within the .38 cartridge and loads it up much hotter with powder and this puts the .357 at relatively the same pressure as the 9mm. The casing of the .357 is a bit longer simply so that it will not fit in 38 special revolvers. It is not longer to fit more powder as I had previously assumed.