Ecstacy has more of an emphathogenic, ego softening effect as opposed to cocaine's more ego-hardening effect. This is due to ecstacy being primarily a serotoninergic, while cocaine is mostly dopaminergic. Those two neurotransmitters are sort of like yin and yang. What they have in common is that they both release dopamine and norepinephrine which are responsible for the stimulating effect. I think cocaine also has a slight serotoninergic effect if you count the 5-HT3 receptor, which mostly just releases dopamine unlike most other 5-HT receptors. wait... this is BDD! ah what the hell. Cocaine no matter the route of administration has a greatly shorter duration than MDMA (ecstacy) and it's analogues. Cocaine will usually last around 30 minutes, and MDMA will last around 3 hours.
They are also both very difficult to find in high purity/quality on the street. They're usually cut with things like amphetamines, ephedrine, sugar, and sometimes even PCP.