GENERIC TRAITS IN STATICALLY TYPED LANGUAGES - How to do It?

Andreas Svendsen, Birger Mller-Pedersen

2008

Abstract

Traits have been proposed as a code reuse mechanism for dynamically typed languages. The paper addresses the issues that come up when introducing traits in statically typed languages, such as Java. These issues can be resolved by introducing generic traits, but at some cost. The paper studies three different generic mechanisms: Java Generics, Templates and Virtual Types, by implementing them all by a preprocessor to Java. The three different approaches are tested by a number of examples. Based on this, the paper gives a first answer to which of the three generic mechanisms that are most adequate.

References

  1. Allen, E., Chase, D., Hallett, J., Luchangco, V., Maessen, J.-W., Ryu, S., Steele Jr., G. L., and Tobin-Hochstadt, S. (2007). The Fortress Language Specification. http://research.sun.com/projects/plrg/fortress.pdf.
  2. Bracha, G. (2004). Generics in the Java Programming Language. http://java.sun.com/j2se/1.5/pdf/genericstutorial.pdf.
  3. Ducasse, S., Nierstrasz, O., Schrli, N., Wuyts, R., and Black, A. P. (2006). Traits: A Mechanism for Finegrained Reuse. ACM Transactions on Programming Languages and Systems (TOPLAS), 28(2):331-388.
  4. Lehrmann Madsen, O. and Mller-Pedersen, B. (1989). Virtual Classes - A Powerful Mechanism in ObjectOriented Programming. In OOPSLA 7889: Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications, pages 397-406, New York, NY, USA. ACM.
  5. Mahmoud, Q. H. (2004). Using and gramming Generics in J2SE 5.0. java.sun.com/developer/technicalArticles/J2SE/ generics/.
  6. Naftalin, M. and Wadler, P. (2007). Java Generics and Collections. O'Reilly Media.
  7. Nierstrasz, O., Ducasse, S., Reichhart, S., and Schrli, N. Adding Traits to (Statically Typed) Languages. Technical Report IAM-05-006.
  8. Quitslund, P. J. (2004). Java Traits - Improving Opportunities for Reuse. Technical Report CSE-04-005, OGI School of Science & Engineering, Beaverton, Oregon, USA.
  9. Reichhart, S. (2005). Traits in CSharp. http:// www.iam.unibe.ch/s˜cg/Archive/Projects/Reic05a.pdf.
  10. Shärli, N., Ducasse, S., Nierstrasz, O., and Black, A. (2002). Traits: Composable Units of Behavior. Technical report.
  11. Studman, M. (2005). Java 5 (aka 1.5) grammar. http:// www.antlr.org/grammar/1090713067533/index.html.
  12. Thorup, K. K. (1997). Genericity in Java with Virtual Types. In ECOOP'97 - European Conference on Object-Oriented Programming, volume 1241, pages 444-471. Springer Verlag.
Download


Paper Citation


in Harvard Style

Svendsen A. and Mller-Pedersen B. (2008). GENERIC TRAITS IN STATICALLY TYPED LANGUAGES - How to do It? . In Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT, ISBN 978-989-8111-51-7, pages 39-46. DOI: 10.5220/0001870700390046


in Bibtex Style

@conference{icsoft08,
author={Andreas Svendsen and Birger Mller-Pedersen},
title={GENERIC TRAITS IN STATICALLY TYPED LANGUAGES - How to do It?},
booktitle={Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT,},
year={2008},
pages={39-46},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0001870700390046},
isbn={978-989-8111-51-7},
}


in EndNote Style

TY - CONF
JO - Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT,
TI - GENERIC TRAITS IN STATICALLY TYPED LANGUAGES - How to do It?
SN - 978-989-8111-51-7
AU - Svendsen A.
AU - Mller-Pedersen B.
PY - 2008
SP - 39
EP - 46
DO - 10.5220/0001870700390046