Typing slowdown
I wrote a little Maple procedure. [It enumerates permutations of a bag/multiset by (as nearly as feasible) adjacent transpositions, in constant amortised time, and I was quite pleased with it though that's neither here nor there.]
Nothing sophisticated: just using very basic features that might easily be ported to or from traditional mainstream languages, say Java or C++.
But it seemed to run rather slowly under Maple 9; so to speed things up a little, and to improve its portability, I decided to try using a feature I had previously ignored: specifying the types of function arguments, results, and local variables.
Now the compiler knows everything will be integer, 1-D array(integer), etc, and I can sit back and watch my test run if not quite like the proverbial shirt off a shovel at least slightly less like syrup off a spoon.
Or maybe not. With types specified, it doesn't actually run any faster.
It doesn't run at the same speed. Or even a bit more leisure(li)ly.
It actually takes 7x longer to run the same test.
That's right folks, execution is seven times slower with typing than without.
For crying out loud! Fred Lunnon (spluttering apoplectically) [July 3rd 2008]
See the procedure in Bag Permutation Generator.
