The .40 S&W was developed specifically for law enforcement needs. It fires rimless, .40 inch (10.16mm) diameter bullets. The .45 ACP (Automatic Colt Pistol) uses bullets with diameters of .452 inches (11.5mm). The energy of the .40 S&W exceeds standard-pressure .45 ACP loadings, generating between 350-foot-pound (470 J) and 500-foot-pound (680 J) of energy, depending on bullet weight.
Contents: .40 S&W vs .45 ACP
edit Production History
The .40 cartridge was designed by Smith & Wesson in 1990.
The .45 was developed by John Browning in 1904. It has been used by the United States and other militaries since World War I.
After the 1986 FBI Miami shootout, where two FBI agents were killed due to lack of adequate power exhibited by their service .38 Special handguns, the FBI started looking for a replacement handgun. They needed something with an increased ammunition capacity, easier reload and reliably functions with a reduced velocity 10mm ammunition (something between the .45 and 10mm). S&W then developed .40cal which matched the performance of a 10mm and could be retrofitted into medium-frame (9mm size) automatic handguns.
During the early 20th century wars (The Philippine–American War, World War I etc), rifles like double action revolvers in .38 Long Colt and .303 British were not proving effective in stopping opponents. After a few tests, the Army and the Cavalry to decide that a minimum of .45-caliber was required in the new handgun. The Cavalry asked for a .45-caliber equivalent Colt modified the pistol design to fire a .45-caliber version of the prototype .41-caliber round. The result from Colt was the Model 1905 and the new .45 ACP cartridge.
.40 cartridges are popular with law enforcement agencies in the United States, Canada and Australia. They have been called “the ideal cartridge for personal defense and law enforcement.”
.45 is a very popular choice for personal defense during a home invasion and in law enforcement.
This video discusses in detail about .40 vs .45 for home defense:
The .40 has a bullet diameter of 10.2mm (.400 in), a neck diameter of 10.7mm, a shoulder diameter of 10.7 mm, a base diameter of 10.8mm, a rim diameter of 10.8mm and a rim thickness of 1.4mm.
The .45 has a bullet diameter of 11.5 mm (.452 in), a neck diameter of 12.0mm, a base diameter of 12.1 mm, and a rim diameter of 12.2 mm.
A .45 ACP is anywhere between 20% and 60% more expensive than a .40.
edit Magazine capacity
Due to the smaller size of the bullet, .40 ACPs typically have a higher magazine capacity than a .45, although the specifics vary depending on the type of gun.
Example: A Glock .40 pistol such as the 35,22,23 & 27 models can hold upto 31 rounds of .40 S&W. A few .45 ACP handguns like HS2000 can hold as many as 14 cartridges. The FNP-45 can hold upto 15 .45 cartridges but this greatly increases the pistol's bulk and hence lowers maneuverability.
A .40 fires bullets with a velocity between 950 and 1440 feet per second, depending on the model.
A .45 fires bullets with an average velocity between 835 and 1150 feet per second.
While the accuracy depends on several factors like the skill of the shooter, the gun used, the size of the barrel, wind velocity etc. at shorter distances (10-20yards), both have nearly equal accuracy. At longer distances, the velocity of the bullet matters. Since .45 has a lower velocity, it has the trajectory which needs to be take into account while firing.
A typical .40 averages between 9.8” and 13.3” penetration. The Winchester FMJ, however, has a penetration of 25”. It expands to between 0.4” and 0.76”.
A .45 averages about 11.3”-14.3” penetration. However, the Remington FMJ has 27” penetration. The cartridge expands to an average of 0.75” inches, but the Remington FMJ expands to 0.45”.
The felt recoil for a .40 is much more than a .45.
The .45 recoil seems to be heavier and pushes one's hands backwards instead of up. It does not have much muzzle flip. 
".40 S&W vs .45 ACP." Diffen.com. Diffen LLC, n.d. Web. 2 Sep 2014. < http://www.diffen.com/difference/.40_S%26W_vs_.45_ACP >