With the introduction of support for generics in mainstream programming languages, we see an renewed interest in writing generic code. Maple offers the possibility to write generic code using module-producing functions. There is usually a performance cost associated with the use of generics, and this paper analyzes the cost of using these in Maple. We created sets of tests for different styles of generics and compared their performance with specialized Maple code. The first set of tests implemented generics in the style of parameterized abstract data types, with Maple modules providing functions that operated on data values. The second set of tests implemented generics in the style of parameterized object-oriented classes, where each data value was embodied in its own module object. The test functions were based on the popular SciMark benchmark for scientific computation in Java. The results show a small degradation of performance when using generics modeled on abstract data types and high performance degradation when using an object-oriented approach. Keywords. generics, parametric polymorphism, performance, Maple.
To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.