Let us begin with the official descriptions of loops. The Maple® documentation claims that:
Note that the examples above don't necessarily illustrate the best way to perform these operations. Often a functional form like
mul is far more efficient.
Mma's tech tutorial also claims that:
If you have a big program full of
Return, etc., you're probably not doing things right.
Often, however, you can make more elegant and efficient programs using the functional programming constructs ….
Also, MatLab's Techniques to Improve Performance and Measure and Improve GPU Performance claims that:
You can achieve better performance by rewriting loops to make use of higher-dimensional operations. The performance of a wide variety of element-wise functions can be improved … instead of looping over the matrices.
Well, I'm confused. Why did the official help page say like this? Actually, I find that lots of users in this forum still (and usually) use traditional
for-loops instead of something which fits in with the alleged functional programming ideas. Did I misconstrue those statements?
(For instance, as for the functional operations, it's unfortunate that Maple's built-in
map cannot operate on arbitrary expression trees of any depth; so I have to use the loops to apply some procedure indirectly, which is not so convenient. In my opinion, owing to such limitation, people have to, and then gradually tend to, use the loops.)