Both cars have amazing ability, the e46 M3 is iconic as it was a performance benchmark for everything for a long time. A few lads at work took my 335i out [they have M3's] and could not believe how fast it was in standard form. Remapped or a JB4 fitted the 335 is a lot quicker. Still does not takeaway the fact that the M3 is a better car though.
One thing i dont like about the 335 compared to the M3 is the body roll, the M3 is a much more planted car through the twisty stuff. In a straight pull off the lights though its a different matter.
Its all horses for courses, the M3 looks better, has more smile appeal and will hold better value if looked after.
You pay your money and take your pick.