Abstract
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Brown, W.E.: Progress toward Opaque Typedefs for C++0X (2005)
Johnston, B.: Java programming today. Pearson Prentice Hall, Upper Saddle River (2004)
Koffman, E.B.: Objects, abstraction, data structures and design using Java. John Wiley and Sons (2005)
Sun Microsystems, Inc. Annotations (2004), http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html
Watt, S.M.: Aldor. In: Grabmeier, J., Kaltofen, E., Weispfenning, V. (eds.) Handbook of Computer Algebra, pp. 265–270. Springer, Heidelberg (2003)
The Apache Ant Project (2010), http://ant.apache.org
Bourdykine, P.: Type Safety without Objects in Java, MSc. Thesis, U. Western Ontario (2009)
Miller, B., Pozo, R.: SciMark 2.0 Java Benchmark. National Institute of Standards and Technology (2004)
Dragan, L., Watt, S.M.: Performance Analysis of Generics for Scientific Computing. In: Proc. SYNASC 2005, pp. 93–100. IEEE Press (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bourdykine, P., Watt, S.M. (2012). Lightweight Abstraction for Mathematical Computation in Java. In: Gerdt, V.P., Koepf, W., Mayr, E.W., Vorozhtsov, E.V. (eds) Computer Algebra in Scientific Computing. CASC 2012. Lecture Notes in Computer Science, vol 7442. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-32973-9_5
Download citation
DOI: https://doi.org/10.1007/978-3-642-32973-9_5
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-32972-2
Online ISBN: 978-3-642-32973-9
eBook Packages: Computer ScienceComputer Science (R0)