Lightweight Abstraction for Mathematical Computation in Java
Many object-oriented programming languages provide type safety by allowing programmers to introduce distinct object types. In the case of Java, having objects as the sole abstraction mechanism also introduces a considerable or even prohibitive cost, especially when dealing with small objects over primitive types. Consequently, Java library implementations frequently avoid abstraction and are not type safe in practice. Many applications, including computer algebra, use values logically belonging to many different non-interchangable types. Languages such as Java are then either unsafe or inefficient to use in these applications. We present a solution allowing type safety in Java with little performance penalty. We do this by introducing a specialzed kind of object that provides distinct types for type checking, but which can always be removed entirely at compile time. In our implementation, programs are compiled twice, first with objects to verify type safety, and then with the objects removed for efficiency. This gives significant performance gains across a range of tests, including the generic SciGMark tests.
KeywordsObject Type Polynomial Multiplication Java Code Primitive Type Type Safety
Unable to display preview. Download preview PDF.
- 1.Brown, W.E.: Progress toward Opaque Typedefs for C++0X (2005)Google Scholar
- 2.Johnston, B.: Java programming today. Pearson Prentice Hall, Upper Saddle River (2004)Google Scholar
- 3.Koffman, E.B.: Objects, abstraction, data structures and design using Java. John Wiley and Sons (2005)Google Scholar
- 4.Sun Microsystems, Inc. Annotations (2004), http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html
- 5.Watt, S.M.: Aldor. In: Grabmeier, J., Kaltofen, E., Weispfenning, V. (eds.) Handbook of Computer Algebra, pp. 265–270. Springer, Heidelberg (2003)Google Scholar
- 6.The Apache Ant Project (2010), http://ant.apache.org
- 7.Bourdykine, P.: Type Safety without Objects in Java, MSc. Thesis, U. Western Ontario (2009)Google Scholar
- 8.Miller, B., Pozo, R.: SciMark 2.0 Java Benchmark. National Institute of Standards and Technology (2004)Google Scholar
- 9.Dragan, L., Watt, S.M.: Performance Analysis of Generics for Scientific Computing. In: Proc. SYNASC 2005, pp. 93–100. IEEE Press (2005)Google Scholar