Detergents are sodium salts of long chain benzene sulphonic acids. The ionic group in soaps is SO−3Na+.
Soaps forms salts in hard water that are insoluble, and will form "scum" on the surface of the water. Detergents are less likely to form alternate salts, but when they do these salts that form are soluble. Hence,
Detergents are considered better than soap.