I have no experience using Mathematica, so I can't comment on that aspect of the debate. But what I wrote definitely isn't wizardry. I just looked at the factors() you wrote, and noticed there were some obvious places where more memory was being allocated than necessary. I just reworked it slightly using push!, which efficiently grows a vector. I have little doubt that you could gain another several-fold boost in performance by:
- integrating the logic of factor() into factors(); in particular, factor() allocates a Dict output, but you could basically weave the code that's in factor() into factors() and skip the need for the Dict. - passing the output in as I suggested in the first email. That way it can re- use the same memory buffer on each call. In general, now that I've been using Julia for a while, I find its performance to be relatively predictable, at least in an order-of-magnitude sense. When you find yourself surprised, it's usually an indication that something needs fixing :-). The "performance tips" page sums up most of the important principles behind writing efficient Julia code. --Tim On Sunday, March 16, 2014 03:53:38 PM Stefan Schwarz wrote: > totally agree with you, reaching predictive performance is something that > seems to be impossible...albeit > Mathematica is a DSL and is there a need for predictability? Is Julia made > for real-time systems? > Do you have predictability using new/delete and/or exceptions in C++? > > Did you expect the performance boost in what Tim wrote? > > The point for me is, that I expect from a scientific computing environment > that I don't have > to reuse old, dirty C-tricks etc. in order to gain speed. I think that is > the strength of Wolfram and > MathWorks, despite all their weaknesses they have and poor design decisions > they've made along the line. > > 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.
