I would say go for an M3 over a 335i. I had one for 2 years (6spd) and compared to my younger brothers 335xi (6spd) I have to say that the M3 out of the box definitely feels more sporty. Better gear box, suspension, overall handling.
The 335i being newer does provide a few benefits thought, much better electronics, bluetooth, sound, ipod/usb hookup etc, better NAV.
In a straightline the 335i is definitely easy to mod to beat an M3 and even stock a 335i is near the M3.
So its really your choice:
More sporty, hard to get more HP, classic design, go for the M3.
Want faster straight line acceleration, but more work to get the sport feel, go with the 335.
Overall though its a tough choice, they are very close to each in just about every category, it also depends on how much if at all you are going to mod both.
No mods I would go with an m3.
With mods, different story.