Recently I've solved quite a number of programming challenges on the project euler site. Most of them I have solved using Wolfram's Mathematica. I am simply amazed how well-designed and easy to use it is as a programming tool. Rich mixture of functional programming tools, pattern matching and "classical" procedural programming. Excellent GUI, marvelous documentation, and it's even pretty fast in execution.

Apart from being an excellent programming language, it's also the best numeric/symbolic/visualization tool available. I have also worked with Matlab and MathCad, and they are below mathematica in almost every respect.

Ok, now for the flaws from the programming perspective. I can see only one - no (explicit) support for lazy lists. I.e. if you want to generate a list of odd numbers less than 100, you can write

Select[Table[i,{i,100}], OddQ]

(ok, this is suboptimal since odd numbers can be generated by 2*i-1 for suitable range of i). I can't know how does it work internally but my guess (based on the time and memory consumption in much larger example) is that it first generates a complete list of the first 100 numbers (the inner Table) command and then filters out even numbers. A better way would be to "streamline" the application of Select and OddQ while the list is generated. Haskell works this way, as far as I understood from little reading about it.


No comments: