A .40 has a very broad range of performance. You load 180 grain bullets and you have power similar to 45 ACP, drop down to 155 grains and you can push em as fast as 115 grain bullets from a 9mm... very effective for SD with as much power as many 357 defense loads but with less flash blast. Then if you really want to step it up, 135 grain rounds at 1450fps are pretty much equal to the popular 125 grain .357 mag loading. The .40 is a niche round between 9mm and 45, but it is a very versatile and widely available round. There are fewer .40 guns in circulation because of it's late start and ammo is sometimes more available for it than 9mm which is non existant right now in California..... I personally think the .40 makes most sense when you have magazine capacity limits of 10 rounds. That's about how many fit in a typical double stack mag with little modification. A 10 shot full size 9mm is a waste of space.
Let's look at the 9mm. Load it light with 90 grain bullets and you can push 1500fps from a handgun. Standard 115 and 124 grain loads are in the 1200fps class and 147 grain subsonic loads in the 950fps class.
45 by comparison allows you to pus 185 grian bullets to only about 1050fps and 230 grain bullets to about 850 within standard pressure loads.
The .45 is a thumper but not necissarily superior to the hot 155 grain .40s in stopping power even when using 185 grain loadings in a 45.