Abstract
We describe a design for generics in Go inspired by previous work on Featherweight Java by Igarashi, Pierce, and Wadler. Whereas subtyping in Java is nominal, in Go it is structural, and whereas generics in Java are defined via erasure, in Go we use monomorphisation. Although monomorphisation is widely used, we are one of the first to formalise it. Our design also supports a solution to The Expression Problem.
Supplemental Material
- Nada Amin and Ross Tate. 2016. Java and Scala's type systems are unsound: the existential crisis of null pointers. In Object-Oriented Programming: Systems, Languages, and Applications (OOPSLA). 838-848.Google Scholar
- Nick Benton, Andrew Kennedy, and George Russell. 1998. Compiling Standard ML to Java Bytecodes. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP '98), Baltimore, Maryland, USA, September 27-29, 1998, Matthias Felleisen, Paul Hudak, and Christian Queinnec (Eds.). ACM, 129-140. https://doi.org/10.1145/ 289423.289435 Google Scholar
Digital Library
- Jasmin Christian Blanchette, Sascha Böhme, Andrei Popescu, and Nicholas Smallbone. 2016. Encoding Monomorphic and Polymorphic Types. Logical Methods in Computer Science 12, 4 ( 2016 ).Google Scholar
- François Bobot and Andrey Paskevich. 2011. Expressing Polymorphic Types in a Many-Sorted Language. In FroCoS (Lecture Notes in Computer Science, Vol. 6989 ). Springer, 87-102.Google Scholar
- Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. 1998. Making the Future Safe for the Past: Adding Genericity to the Java Programming Language. In Proceedings of the 1998 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages & Applications (OOPSLA '98), Vancouver, British Columbia, Canada, October 18-22, 1998. ACM, 183-200. https://doi.org/10.1145/286936.286957 Google Scholar
Digital Library
- Peter Canning, William Cook, Walter Hill, Walter Olthof, and John C Mitchell. 1989. F-bounded polymorphism for object-oriented programming. In Functional Programming Languages and Computer Architecture (FPCA). 273-280.Google Scholar
- Henry Cejtin, Suresh Jagannathan, and Stephen Weeks. 2000. Flow-directed closure conversion for typed languages. In European Symposium on Programming (ESOP). Springer, 56-71.Google Scholar
Cross Ref
- Koen Claessen, Jonas Duregård, and Michał Pałka. 2015. Generating constrained random data with uniform distribution. Journal of Functional Programming 25 ( 2015 ). https://doi.org/10.1017/s0956796815000143 Google Scholar
Cross Ref
- William R Cook. 1990. Object-oriented programming versus abstract data types. In Workshop of the REX Project (LNCS, Vol. 489 ). Springer, 151-178.Google Scholar
- Karl Crary, Stephanie Weirich, and J. Gregory Morrisett. 1998. Intensional Polymorphism in Type-Erasure Semantics. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP '98), Baltimore, Maryland, USA, September 27-29, 1998. ACM, 301-312. https://doi.org/10.1145/289423.289459 Google Scholar
Digital Library
- Sophia Drossopoulou and Susan Eisenbach. 1997. Java is type safe-probably. In European Conference on Object-Oriented Programming. Springer, 389-418.Google Scholar
Cross Ref
- Jonas Duregård. 2016. Automating Black-Box Property Based Testing. Ph.D. Dissertation. Chalmers University of Technology.Google Scholar
- Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. 1998. Classes and Mixins. In Principles of Programming Languages (POPL). 171-183.Google Scholar
- Matthew Fluet. 2015. MLton-Monomorphise. http://mlton.org/Monomorphise.Google Scholar
- Ben Greenman, Fabian Muehlboeck, and Ross Tate. 2014. Getting F-bounded polymorphism into shape. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI '14, Edinburgh, United Kingdom-June 09-11, 2014. 89-99. https://doi.org/10.1145/2594291.2594308 Google Scholar
Digital Library
- Robert Griesemer, Raymond Hu, Wen Kokke, Julien Lange, Ian Lance Taylor, Bernardo Toninho, Philip Wadler, and Nobuko Yoshida. 2020. Featherweight Go. CoRR abs/ 2005.11710 ( 2020 ). arXiv: 2005.11710 https://arxiv.org/abs/ 2005.11710Google Scholar
- Robert Griesemer, Rob Pike, Ken Thompson, Ian Taylor, Russ Cox, Jini Kim, and Adam Langley. 2009. Hey! Ho! Let's Go! https://opensource.googleblog.com/ 2009 /11/hey-ho-lets-go.htmlGoogle Scholar
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. 1999. Featherwieght Java: A Minimal Core Calculus for Java and GJ. In Proceedings of the 1999 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages & Applications (OOPSLA '99), Denver, Colorado, USA, November 1-5, 1999., Brent Hailpern, Linda M. Northrop, and A. Michael Berman (Eds.). ACM, 132-146. https://doi.org/10.1145/320384.320395 Google Scholar
Digital Library
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. 2001. Featherweight Java: a minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst. 23, 3 ( 2001 ), 396-450. https://doi.org/10.1145/503502.503505 Google Scholar
Digital Library
- Mark P Jones. 1995. Dictionary-free overloading by partial evaluation. Lisp and Symbolic Computation 8, 3 ( 1995 ), 229-248.Google Scholar
- Andrew Kennedy and Don Syme. 2001. Design and Implementation of Generics for the.NET Common Language Runtime. In Proceedings of the 2001 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Snowbird, Utah, USA, June 20-22, 2001. ACM, 1-12. https://doi.org/10.1145/378795.378797 Google Scholar
Digital Library
- Shriram Krishnamurthi, Matthias Felleisen, and Daniel P Friedman. 1998. Synthesizing object-oriented and functional design to promote re-use. In European Conference on Object-Oriented Programming (ECOOP). Springer, 91-113.Google Scholar
Cross Ref
- Xavier Leroy. 1992. Unboxed Objects and Polymorphic Typing. In Conference Record of the Nineteenth Annual ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, Albuquerque, New Mexico, USA, January 19-22, 1992. ACM Press, 177-188. https://doi.org/10.1145/143165.143205 Google Scholar
Digital Library
- Maurice Naftalin and Philip Wadler. 2006. Java generics and collections. O'Reilly. http://www.oreilly.de/catalog/javagenerics/ index.htmlGoogle Scholar
- Tobias Nipkow and David von Oheimb. 1998. Javalight is Type-safe-Definitely. In Principles of Programming Languages (POPL). 161-170.Google Scholar
- Benjamin C. Pierce. 1992. Bounded Quantification is Undecidable. In Conference Record of the Nineteenth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Albuquerque, New Mexico, USA, January 19-22, 1992. 305-315. https://doi.org/10.1145/143165.143228 Google Scholar
Digital Library
- John C Reynolds. 1994. User-defined types and procedural data structures as complementary approaches to data abstraction. In New Directions in Algorithmic Languages. MIT Press, 13-23.Google Scholar
- Colin Runciman, Matthew Naylor, and Fredrik Lindblad. 2008. Smallcheck and lazy smallcheck. In Proceedings of the first ACM SIGPLAN symposium on Haskell-Haskell '08. ACM Press. https://doi.org/10.1145/1411286.1411292 Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. 2006. A Semantic Analysis of C++ Templates. In European Conference on Object-Oriented Programming (ECOOP) (LNCS, Vol. 4067 ). Springer, 304-327.Google Scholar
- Bjarne Stroustrup. 2013. The C+ + Programming Language, 4th Edition. Addison-Wesley.Google Scholar
- Wouter Swierstra. 2008. Data types à la carte. Journal of Functional Programming 18, 4 ( 2008 ), 423-436.Google Scholar
Digital Library
- Don Syme. 1999. Proving Java Type Soundness. In Formal Syntax and Semantics of Java. Springer-Verlag, 83-118.Google Scholar
- Akira Tanaka, Reynald Afeldt, and Jacques Garrigue. 2018. Safe Low-level Code Generation in Coq Using Monomorphization and Monadification. JIP 26 ( 2018 ), 54-72.Google Scholar
- Ian Lance Taylor and Robert Griesemer. 2019. Contracts-Draft Design. https://go.googlesource.com/proposal/+/master/ design/go2draft-contracts.mdGoogle Scholar
- Ian Lance Taylor and Robert Griesemer. 2020. Type Parameters-Draft Design. https://go.googlesource.com/proposal/+/ refs/heads/master/design/go2draft-type-parameters.mdGoogle Scholar
- The Go Team. 2020. The Go Programming Language Specification. https://golang.org/ref/specGoogle Scholar
- The Rust Team. 2017. The Rust programming language. http://rust-lang.org/Google Scholar
- Andrew P. Tolmach and Dino Oliva. 1998. From ML to Ada: Strongly-Typed Language Interoperability via Source Translation. Journal of Functional Programming 8, 4 ( 1998 ), 367-412.Google Scholar
Digital Library
- Mads Torgersen. 2004. The expression problem revisited. In European Conference on Object-Oriented Programming (ECOOP). Springer, 123-146.Google Scholar
Cross Ref
- Aaron Turon. 2015. Abstraction without overhead: traits in Rust. https://blog.rust-lang.org/ 2015 /05/11/traits.htmlGoogle Scholar
- Mirko Viroli and Antonio Natali. 2000. Parametric polymorphism in Java: an approach to translation based on reflective features. In Proceedings of the 2000 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages & Applications (OOPSLA 2000 ), Minneapolis, Minnesota, USA, October 15-19, 2000. ACM, 146-165. https://doi.org/10.1145/ 353171.353182 Google Scholar
Digital Library
- Philip Wadler. 1998. The expression problem. Posted on the Java Genericity mailing list. http://homepages.inf.ed.ac.uk/ wadler/papers/expression/expression.txtGoogle Scholar
- Dachuan Yu, Andrew Kennedy, and Don Syme. 2004. Formalization of generics for the.NET common language runtime. In Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2004, Venice, Italy, January 14-16, 2004. ACM, 39-51. https://doi.org/10.1145/964001.964005 Google Scholar
Digital Library
- Matthias Zenger and Martin Odersky. 2004. Independently extensible solutions to the expression problem. Technical Report.Google Scholar
Index Terms
Featherweight go
Recommendations
Self type constructors
OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applicationsBruce and Foster proposed the language LOOJ, an extension of Java with the notion of MyType, which represents the type of a self reference and changes its meaning along with inheritance. MyType is useful to write extensible yet type-safe classes for ...
Generalized algebraic data types and object-oriented programming
OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applicationsGeneralized algebraic data types (GADTs) have received much attention recently in the functional programming community. They generalize the (type) parameterized algebraic datatypes (PADTs) of ML and Haskell by permitting value constructors to return ...
Self type constructors
OOPSLA '09Bruce and Foster proposed the language LOOJ, an extension of Java with the notion of MyType, which represents the type of a self reference and changes its meaning along with inheritance. MyType is useful to write extensible yet type-safe classes for ...






Comments