Owning a highly modded 335i, here's my 2cents:
It all depends on your priorities and the depth of your pocket.
When I first got the 335i, I thought performance and handling were great. But as you get used to the car, you realize the shortcomings (handling mostly) and the potential (performance). That's where the modding started and things got ugly
Not going into full details, but let's say that $30k in mods later, I have a car which makes me not long for an M3
Did I expect to dump that much in the car when I got it? No way!! But both the mod bug and the tracking bug bit me badly! And to make a 335i perform and be reliable on a racetrack takes alot of work. But to some extent the same applies to the M3. And modding an M3 is even more expensive.
My verdict is that if you're looking into a complete sports car package from the factory, the M3 may be a better choice.
If you're not afraid to go down the slippery modding slope, the 335i has a LOT of potential while still maintaining it's advantages: way better mpg (gas prices in Europe are high and driving to the gas station weekly would piss me off), heaps of torque at low/mid rpm (great for daily driving), lower insurance and running costs.