Per the numbers (velocity and energy) a normal (Winchester, Remington, Federal, Speer, Hornady) 155gr .40 S&W loading and a normal 158gr .357 Magnum loading are quite similar. Both will normally run in the 1200-1250fps range from a full-sized service type gun (4" barrel semi-auto for the .40 and 4" revolver for the .357) and in the 1100-1150fps range from a compact gun (3" barrel semi-auto for the .40 and 2" barrel for the .357).
Lighter bullets are also, per the numbers, quite similar as a 135gr .40 will normally run in the 1300-1350fps range from a full-size gun while the slightly lighter 125gr .357's will typically run in the 1400-1450fps range from a 4" revolver.
Numbers, however, is where the similarities between the two cartridges ends. .40 S&W, for the most part, performs about like most other service-type semi-auto cartridges (9mm, .357 Sig, and .45 ACP). With modern premium loadings, penetration in bare gelatin usually runs in the 12-14" range with expansion in the .55-.70" range while weight retention is usually 90% or more. This seems to be about the best performance that can be had with bullets that are limited by the necessity of feeding reliability in a semi-automatic handgun.
.357 Magnum loadings, however, do not share the same design constraints as semi-auto loadings do because the .357 Magnum is primarily a revolver cartridge and feeding reliability is a non-issue in that platform. If semi-auto like performance is desired, many loadings such as Remington's 125gr Golden Saber, Cor-Bon's 125gr DPX, and Winchester's 125gr PDX1 can deliver it, but other .357 Magnum loadings are capable of performance that isn't possible with a semi-auto round. The older semi-jacketed loadings, particularly the 125gr Remington and Federal versions, are some of the few handgun cartridges capable of producing significant fragmentation while still meeting the FBI's 12" minimum penetration standard. Heavier fully-jacketed loadings like Winchester's 145gr Silvertip, Federal's 158gr Hydra-Shok, and Speer's 158gr Gold Dot are capable of delivering expansion and weight retention similar to the semi-auto loadings but penetration depths of 16-20"
Also, once you step outside of 'normal' loadings and start looking at what's available from boutique makers like Buffalo Bore, Double Tap, and Grizzly, the .357 Magnum is capable of much higher velocities and energies than even the boutique .40 S&W loadings (at this point, the .357 Magnum is much more comparable to a full-power 10mm Auto). This is because the .357 Magnum was originally loaded all-out with 1930's powders and primers. Over the years, the cartridge has been downloaded substantially and has not seen nearly the load development over the last 30 years that the semi-auto rounds have. When loaded to its full potential, the .357 Magnum is capable of spectacular ballistics that rival low-end .41 Magnum loadings.
The .40 S&W, on the other hand, was developed over 50 years later than the .357 Magnum and has not been downloaded. As such loading it to the ragged edge provides much more modest ballistic improvements because it's normal loadings are already nearly topped-out.
Ballistics and terminal performance, however, are not the end of the story. Even with comparable loadings, a .357 Magnum revolver will have substantially more felt recoil than a .40 Semi-Auto of similar size and weight. Also, both cartridges are normally found in different platforms which offer significant advantages and disadvantages to each other which have been discussed thoroughly in other threads. In my mind, the choice between them really boils down to whether you prefer a revolver or a semi-automatic as either one is a perfectly capable defensive cartridge that will serve you well so long as you do your part. I personally like the .357 Magnum better, but that's mainly because I'm a revolver guy.