On Sunday, March 16, 2014 6:53:38 PM UTC-4, Stefan Schwarz wrote: > > Something that Tim wrote must come naturally in such a domain like Julia > e.g. is in. > If not, it is just wizardry and something you can gain as a power user of > Mathematica/Matlab > as well...somehow. If this is for wizards only, then it is nothing else > but another > programming language. >
What Tim did seems pretty straightforward to me: higher-order functions and repeated memory allocation in inner loops are slow compared to plain loops over scalar variables and pre-allocated arrays. Performance optimization in any language requires some understanding of what the machine is actually doing. When you have performance-critical inner-loop code and you need to optimize it in Julia, you use plain loops, pre-allocate arrays once before the loop starts, and take some care to maintain type stability. Whereas in other high-level dynamic languages when you have performance-critical inner-loop code that you need to optimize, you often have no choice but to rewrite it in C (using plain loops and pre-allocated arrays). (Of course, most code is not performance-critical inner-loop code, and so most of the time you can use the convenient higher-level abstractions.)
