It is very reasonable for you to obtain those performances in MMA. I think that you must obey some certain rules when you try to define a function, in any programming language. In MMA, people usually use SetDelayed (:=) as the major tool for function defining.