Abstract
Generalized interfaces are an extension of the interface concept found in object-oriented languages such as Java or C#. The extension is inspired by Haskell's type classes. It supports retroactive and type-conditional interface implementations, binary methods, symmetric multimethods, interfaces over families of types, and static interface methods.
This article reports practical experience with generalized interfaces as implemented in the JavaGI language. Several real-world case studies demonstrate how generalized interfaces provide solutions to extension and integration problems with components in binary form, how they make certain design patterns redundant, and how they eliminate various run-time errors. In each case study, the use of JavaGI results in elegant and highly readable code.
Furthermore, the article discusses the implementation of a compiler and a run-time system for JavaGI. Benchmarks show that our implementation offers acceptable performance.
- G. Baumgartner, M. Jansche, and K. Läufer. Half&half: Multiple dispatch and retroactive abstraction for Java. Technical Report OSU-CISRC-5/01-TR08, Revised 3/02, Ohio State University, 2002.Google Scholar
- S. M. Blackburn et al. The DaCapo benchmarks: Java benchmarking development and analysis. In OOPSLA'06 OOPSLA2006, pages 169--190. Google ScholarDigital Library
- G. Bracha. Generics in the Java programming language. http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf, 2004.Google Scholar
- G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA'98 OOPSLA1998, pages 183--200. Google ScholarDigital Library
- K. B. Bruce, L. Cardelli, G. Castagna, J. Eifrig, S. F. Smith, V. Trifonov, G. T. Leavens, and B. C. Pierce. On binary methods. Theory and Practice of Object Systems, 1(3):221--242, 1995. Google ScholarDigital Library
- K. B. Bruce and J. N. Foster. LOOJ: Weaving LOOM into Java. In M. Odersky, editor, 18th ECOOP, volume 3086 of LNCS, pages 389--413, Oslo, Norway, 2004. Springer.Google Scholar
- N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In J. Vitek, editor, 22nd ECOOP, volume 5142 of LNCS, Paphos, Cyprus, 2008. Springer. Google ScholarDigital Library
- M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In B. C. Pierce, editor, Proc. ICFP 2005, pages 241--253, Tallinn, Estonia, 2005. ACM Press, New York. Google ScholarDigital Library
- M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. In M. Abadi, editor, Proc. 32nd ACM Symp. POPL, pages 1--13, Long Beach, CA, USA, 2005. ACM Press. Google ScholarDigital Library
- C. Chambers. Object-oriented multi-methods in Cecil. In O. L. Madsen, editor, 6th ECOOP, volume 615 of LNCS, pages 33--56. Springer, 1992. Google ScholarDigital Library
- C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In Proc. 15th ACM Conf. OOPSLA, pages 130--145, Minneapolis, MN, USA, 2000. ACM Press, New York. Google ScholarDigital Library
- C. Clifton, T. Millstein, G. T. Leavens, and C. Chambers. MultiJava: Design rationale, compiler implementation, and applications. ACM TOPLAS, 28(3):517--575, 2006. Google ScholarDigital Library
- dom4j. http://www.dom4j.org/, 2008.Google Scholar
- Eclipse Foundation. Eclipse compiler for Java. http://download.eclipse.org/eclipse/downloads/drops/R-3.4.1-20080911170%0/index.php, 2008.Google Scholar
- B. Emir, A. Kennedy, C. V. Russo, and D. Yu. Variance and generalized constraints for C# generics. In 20th ECOOP, volume 4067 of LNCS, pages 279--303, Nantes, France, 2006. Springer. Google ScholarDigital Library
- E. Ernst. Family polymorphism. In J. L. Knudsen, editor, 15th ECOOP, volume 2072 of LNCS, pages 303--326, Budapest, Hungary, 2001. Springer. Google ScholarDigital Library
- E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995. Google ScholarDigital Library
- R. Garcia, J. Järvi, A. Lumsdaine, J. G. Siek, and J. Willcock. A comparative study of language support for generic programming. In OOPSLA'03, pages 115--134. Google ScholarDigital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison-Wesley, 3rd edition, 2005. Google ScholarDigital Library
- D. Gregor, J. Järvi, J. Siek, B. Stroustrup, G. Dos Reis, and A. Lumsdaine. Concepts: Linguistic support for generic programming in C++. In OOPSLA'06, pages 291--310. Google ScholarDigital Library
- S. S. Huang, D. Zook, and Y. Smaragdakis. cJ: Enhancing Java with safe type conditions. In Proc. 6th AOSD, pages 185--198, Vancouver, BC, Canada, 2006. ACM Press, New York. Google ScholarDigital Library
- J. Hunter and B. McLaughlin. JDOM. http://www.jdom.org/, 2007.Google Scholar
- A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS, 23(3):396--450, 2001. Google ScholarDigital Library
- Jaxen. http://jaxen.codehaus.org/, 2008.Google Scholar
- M. P. Jones. Type classes with functional dependencies. In G. Smolka, editor, Proc. 9th ESOP, volume 1782 of LNCS, pages 230--244, Berlin, Germany, 2000. Springer. Google ScholarDigital Library
- J. Järvi, J. Willcock, and A. Lumsdaine. Associated types and constraint propagation for mainstream object-oriented generics. In Proc. 20th ACM Conf. OOPSLA, pages 1--19, New York, NY, USA, 2005. ACM Press. Google ScholarDigital Library
- T. Lindholm and F. Yellin. The Java Virtual Machine Specification. Addison-Wesley, second edition, 1999. Google ScholarDigital Library
- V. Litvinov. Contraint-based polymorphism in Cecil: Towards a practical and static type system. In OOPSLA'98, pages 388--411. Google ScholarDigital Library
- R. Lämmel and K. Ostermann. Software extension and integration with type classes. In GPCE '06, pages 161--170, New York, NY, USA, 2006. ACM Press. Google ScholarDigital Library
- M. Mezini and K. Ostermann. Integrating independent components with on-demand remodularization. In Proc. 17th ACM Conf. OOPSLA, pages 52--67, Seattle, WA, USA, 2002. ACM Press, New York. Google ScholarDigital Library
- T. Millstein, M. Reay, and C. Chambers. Relaxed MultiJava: Balancing extensibility and modular typechecking. In OOPSLA'03, pages 224--240. Google ScholarDigital Library
- A. Moors, F. Piessens, and M. Odersky. Generics of a higher kind. In G. E. Harris, editor, Proc. 23rd ACM Conf. OOPSLA, pages 423--438, Nashville, TN, USA, 2008. ACM Press, New York. Google ScholarDigital Library
- N. Myers. A new and useful template technique: 'traits'. In S. B. Lippman, editor, C++ gems, pages 451--457. SIGS Publications, Inc., New York, NY, USA, 1996. Google ScholarDigital Library
- M. Odersky. The Scala language specification version 2.7, 2008. Draft, http://www.scala-lang.org/docu/files/ScalaReference.pdf.Google Scholar
- OMG. Unified modelling language specification, version 1.5, 2003.Google Scholar
- Proc. 18th ACM Conf. OOPSLA, Anaheim, CA, USA, 2003. ACM Press, New York.Google Scholar
- Proc. 21th ACM Conf. OOPSLA, Portland, OR, USA, 2006. ACM Press, New York.Google Scholar
- Proc. 13th ACM Conf. OOPSLA, Vancouver, BC, Canada, 1998. ACM Press, New York.Google Scholar
- H. Ossher and P. Tarr. Using subject-oriented programming to overcome common problems in object-oriented software development/evolution. In Proc. 21th ICSE, pages 687--688, Los Angeles, CA, USA, 1999. ACM. Google ScholarDigital Library
- S. Peyton Jones, editor. Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, 2003.Google Scholar
- S. Peyton Jones, M. Jones, and E. Meijer. Type classes: An exploration of the design space. In J. Launchbury, editor, Proc. of the Haskell Workshop, Amsterdam, The Netherlands, 1997.Google Scholar
- A. Shalit. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Programming Language. Addison-Wesley, Reading, MA, 1997. Google ScholarDigital Library
- G. Steele. Common LISP: The Language. Digital Press, Bedford, MA, 2nd edition, 1990. Google ScholarDigital Library
- P. Thiemann. An embedded domain-specific language for type-safe server-side Web-scripting. ACM TOIT, 5(1):1--46, 2005. Google ScholarDigital Library
- M. Torgersen, E. Ernst, C. P. Hansen, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. Journal of Object Technology, 3(11):97--116, 2004.Google ScholarCross Ref
- P. Wadler. The expression problem, 1998. Posted on Java Genericity mailing list.Google Scholar
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In Proc. 16th ACM Symp. POPL, pages 60--76, Austin, Texas, USA, 1989. ACM Press. Google ScholarDigital Library
- A. Warth, M. Stanojevic, and T. Millstein. Statically scoped object adaptation with expanders. In OOPSLA'06, pages 37--56. Google ScholarDigital Library
- S. Wehr. Formalizing CoreGI. Technical Report 248, Universitat Freiburg, 2009. ftp://ftp.informatik.uni-freiburg.de/documents/reports/report248/report%00248.ps.gz.Google Scholar
- S. Wehr. Javagi homepage. http://www.informatik.uni-freiburg.de/ wehr/javagi, 2009.Google Scholar
- S. Wehr, R. Lämmel, and P. Thiemann. JavaGI: Generalized interfaces for Java. In E. Ernst, editor, 21st ECOOP, volume 4609 of LNCS, pages 347--372, Berlin, Germany, 2007. Springer. Google ScholarDigital Library
- S. Wehr and P. Thiemann. Subtyping existential types. In 10th FTfJP, \textrminformal proceedings, 2008. http://www.informatik.uni-freiburg.de/ wehr/publications/subex.pdf.Google Scholar
- S. Wehr and P. Thiemann. JavaGI in the battlefield: Practical experience with generalized interfaces (extended version). Technical Report 247, Universitat Freiburg, 2009. ftp://ftp.informatik.uni-freiburg.de/documents/reports/report247/report%00247.ps.gz.Google Scholar
- XML path language (XPath) version 1.0. http://www.w3.org/TR/xpath, 1999.Google Scholar
- D. Yu, A. Kennedy, and D. Syme. Formalization of generics for the .NET common language runtime. In X. Leroy, editor, Proc. 31st ACM Symp. POPL, pages 39--51, Venice, Italy, 2004. ACM Press. Google ScholarDigital Library
Index Terms
- JavaGI in the battlefield: practical experience with generalized interfaces
Recommendations
JavaGI in the battlefield: practical experience with generalized interfaces
GPCE '09: Proceedings of the eighth international conference on Generative programming and component engineeringGeneralized interfaces are an extension of the interface concept found in object-oriented languages such as Java or C#. The extension is inspired by Haskell's type classes. It supports retroactive and type-conditional interface implementations, binary ...
JavaGI: The Interaction of Type Classes with Interfaces and Inheritance
The language JavaGI extends Java 1.5 conservatively by a generalized interface mechanism. The generalization subsumes retroactive and type-conditional interface implementations, binary methods, symmetric multiple dispatch, interfaces over families of ...
JavaGI: generalized interfaces for java
ECOOP'07: Proceedings of the 21st European conference on Object-Oriented ProgrammingJavaGI is an experimental language that extends Java 1.5 by generalizing the interface concept to incorporate the essential features of Haskell's type classes. In particular, generalized interfaces cater for retroactive and constrained interface ...
Comments