Nothing Special   »   [go: up one dir, main page]

skip to main content
article
Open access

Jam---designing a Java extension with mixins

Published: 01 September 2003 Publication History

Abstract

In this paper we present Jam, an extension of the Java language supporting mixins, that is, parametric heir classes. A mixin declaration in Jam is similar to a Java heir class declaration, except that it does not extend a fixed parent class, but simply specifies the set of fields and methods a generic parent should provide. In this way, the same mixin can be instantiated on many parent classes, producing different heirs, thus avoiding code duplication and largely improving modularity and reuse. Moreover, as happens for classes and interfaces, mixin names are reference types, and all the classes obtained by instantiating the same mixin are considered subtypes of the corresponding type, and hence can be handled in a uniform way through the common interface. This possibility allows a programming style where different ingredients are "mixed" together in defining a class; this paradigm is somewhat similar to that based on multiple inheritance, but avoids its complication.The language has been designed with the main objective in mind to obtain, rather than a new theoretical language, a working and smooth extension of Java. That means, on the design side, that we have faced the challenging problem of integrating the Java overall principles and complex type system with this new notion; on the implementation side, it means that we have developed a Jam-to-Java translator which makes Jam sources executable on every Java Virtual Machine.

References

[1]
Ancona, D., Lagorio, G., and Zucca, E. 2000. Jam: A smooth extension of Java with mixins. In ECOOP'00---European Conference on Object-Oriented Programming, E. Bertino, Ed. Lecture Notes in Computer Science, vol. 1850. Springer, Berlin, Germany, 154--178.]]
[2]
Ancona, D., Lagorio, G., and Zucca, E. 2001. A core calculus for Java exceptions. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications 2001. ACM Press, New York, NY.]]
[3]
Ancona, D. and Zucca, E. 1998. A theory of mixin modules: Basic and derived operators. Math. Struct. Comput. Sci. 8, 4 (Aug.), 401--446.]]
[4]
Ancona, D. and Zucca, E. 2001. True modules for Java-like languages. In ECOOP'01---European Conference on Object-Oriented Programming, J. Knudsen, Ed. Lecture Notes in Computer Science, vol. 2072. Springer, Berlin, Germany, 354--380.]]
[5]
Ancona, D. and Zucca, E. 2002. A calculus of module systems. J. Funct. Program. 12, 2 (March), 91--132.]]
[6]
Banavar, G. and Lindstrom, G. 1996. An application framework for module composition tools. In ECOOP'96---European Conference on Object-Oriented Programming. Lecture Notes in Computer Science, vol. 1098. Springer, Berlin, Germany, 91--113.]]
[7]
Bauer, L., Appel, A., and Felten, E. 1999. Mechanisms for secure modular programming in Java. Tech. Rep. CS-TR-603-99, Department of Computer Science, Princeton University, Princeton, NJ.]]
[8]
Bono, V., Patel, A., and Shmatikov, V. 1999. A core calculus of classes and mixins. In ECOOP'00---European Conference on Object-Oriented Programming, R. Guerraoui, Ed. Lecture Notes in Computer Science, vol. 1628. Berlin, Germany, 43--66.]]
[9]
Booch, G., Rumbaugh, J., and Jacobson, J. 1998. Unified Modeling Language User Guide. Addison-Wesley, Reading, MA.]]
[10]
Bracha, G. 1992. The programming language JIGSAW: Mixins, modularity and multiple inheritance. Ph.D. thesis, Department of Computer Science, University of Utah, Salt Lake City, Utah.]]
[11]
Bracha, G. and Cook, W. 1990. Mixin-based inheritance. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications 1990. SIGPLAN Not. 25, 10, 303--311.]]
[12]
Bracha, G. and Griswold, D. 1996. Extending Smalltalk with mixins. In OOPSLA96 Workshop on Extending the Smalltalk Language. Electronic note available online at http://www. javasoft.com/people/gbracha/mwp.html.]]
[13]
Bracha, G. and Lindstrom, G. 1992. Modularity meets inheritance. In Proceedings of the International Conference on Computer Languages. IEEE Computer Society, Press, Los Alamitos, CA, 282--290.]]
[14]
Bracha, G., Odersky, M., Stoutmire, D., and Wadler, P. 1998. Making the future safe for the past: Adding genericity to the Java programming language. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications 1998. Available online at http://www.cs.bell-labs.com/who/wadler/pizza/gj/.]]
[15]
Drossopoulou, S. and Eisenbach, S. 1999. Describing the semantics of Java and proving type soundness. In Formal Syntax and Semantics of Java, J. Alves-Foss, Ed. Lecture Notes in Computer Science, vol. 1523. Springer, Berlin, Germany, 41--82.]]
[16]
Drossopoulou, S., Eisenbach, S., and Wragg, D. 1999. A fragment calculus---towards a model of separate compilation, linking and binary compatibility. In Proceedings of the IEEE Symposium on Logic in Computer Science. IEEE Computer Society Press, Los Alamitos, CA.]]
[17]
Duggan, D. and Sourelis, C. 1996. Mixin modules. In Proceedings of the International Conference on Functional Programming. ACM Press, New York, NY, 262--273.]]
[18]
Fisher, K. and Reppy, J. 1999. The design of a class mechanism for Moby. In PLDI'99---ACM Conference on Programming Language Design and Implementation. ACM Press, New York, NY, 37--49.]]
[19]
Flatt, M., Krishnamurthi, S., and Felleisen, M. 1998. Classes and mixins. In ACM Symposium on Principles of Programming Languages 1998. ACM Press, New York, NY, 171--183.]]
[20]
Gamma, E., Helm, R., Johnson, R., and Vlissides, J. 1995. Design Patterns: Elements od Reusable Object-Oriented Software. Addison-Wesley Professional Computing Series. Addison-Wesley, Reading, MA.]]
[21]
Gosling, J., Joy, B., Steele, G., and Bracha, G. 2000. The JavaTM Language Specification, 2nd ed. Addison-Wesley, Reading, MA.]]
[22]
Keene, S. 1989. Object Oriented Programming in Common Lisp: A Programming Guide in CLOS. Addison-Wesley, Reading, MA.]]
[23]
McDirmid, S., Flatt, M., and Hsieh, W. 2001. Jiazzi: New age components for old fashioned Java. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications 2001. ACM Press, New York, NY.]]
[24]
Meyers, A., Bank, J., and Liskov, B. 1997. Parameterized types for Java. In ACM Symposium on Principles of Programming Languages 1997. ACM Press, New York, NY.]]
[25]
Moon, D. 1986. Object oriented programming with flavors. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications 1986. ACM Press, New York, NY, 1--8.]]
[26]
Odersky, M. and Wadler, P. 1997. Pizza into Java: Translating theory into practice. In ACM Symposium on Principles of Programming Languages 1997. ACM Press, New York, NY.]]
[27]
Snyder, A. 1986. CommonObjects: An overview. SIGPLAN Not. 2, 10, 19--28.]]

Cited By

View all

Recommendations

Reviews

Axel T. Schreiner

A mixin is similar to an abstract class: it establishes a reference type, and contains field and method declarations, and in particular, method implementations. Unlike an abstract class, a mixin does not declare a parent class, but instead declares a set of fields and methods that it expects to inherit. Mixins are designed to reuse code in otherwise unrelated classes, and to establish a common reference type for classes instantiating the same mixin. This paper discusses the design, rationale, and implementation of Jam, a mixin system for Java 1.0 (without inner classes), and provides a formal definition of the type system of a slightly reduced subset of the extended language and of its translation to Java. It concludes with a close look at related work: other mixin designs, parametric types, and the system's relationship to modules. The paper should be interesting to both language designers and users. While about two-thirds of the paper is devoted to formal treatments, the informal sections on the language definition, rationale, translation, and implementation are an excellent overview of the design complications, and of the design choices made to overcome them. This makes using mixins that much easier. The paper emphasizes that Jam is a working extension of Java, and the authors provide a download of their system. A slightly more recent paper [1] reports on how traits (essentially mixins without a reference type and with more composition operations) were used to improve the architecture of the Smalltalk collection classes. Mixins compare favorably with traits; it would have been instructive to see a similar, real-life application of Jam as part of this paper. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 25, Issue 5
September 2003
164 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/937563
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 September 2003
Published in TOPLAS Volume 25, Issue 5

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Java
  2. language design

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)68
  • Downloads (Last 6 weeks)11
Reflects downloads up to 16 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2023)Making a Type Difference: Subtraction on Intersection Types as Generalized Record OperationsProceedings of the ACM on Programming Languages10.1145/35712247:POPL(893-920)Online publication date: 11-Jan-2023
  • (2017)XtraitjJournal of Systems and Software10.1016/j.jss.2016.07.035131:C(419-441)Online publication date: 1-Sep-2017
  • (2017)Disjoint PolymorphismProgramming Languages and Systems10.1007/978-3-662-54434-1_1(1-28)Online publication date: 25-Apr-2017
  • (2016)Incremental Rebinding with Name PolymorphismElectronic Notes in Theoretical Computer Science (ENTCS)10.1016/j.entcs.2016.03.003322:C(19-34)Online publication date: 18-Apr-2016
  • (2015)Implementing type-safe software product lines using parametric traitsScience of Computer Programming10.1016/j.scico.2013.07.01697:P3(282-308)Online publication date: 1-Jan-2015
  • (2014)Using dynamic mixins to implement design patternsProceedings of the 19th European Conference on Pattern Languages of Programs10.1145/2721956.2721991(1-19)Online publication date: 9-Jul-2014
  • (2014)Generic traits for the Java platformProceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and Tools10.1145/2647508.2647518(5-16)Online publication date: 23-Sep-2014
  • (2014)A meta-circular language for active librariesScience of Computer Programming10.1016/j.scico.2014.05.00395:P2(219-253)Online publication date: 1-Dec-2014
  • (2014)Verifying traits: an incremental proof system for fine-grained reuseFormal Aspects of Computing10.1007/s00165-013-0278-326:4(761-793)Online publication date: 1-Jul-2014
  • (2013)Reified type parameters using Java annotationsACM SIGPLAN Notices10.1145/2637365.251722349:3(61-64)Online publication date: 27-Oct-2013
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media