skip to main content

Featherweight go

Published:13 November 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a video presentation of the OOPSLA 2020 paper Featherweight Go, by Robert Griesemer, Raymond Hu, Wen Kokke, Julien Lange, Ian Lance Taylor, Bernardo Toninho, Philip Wadler, and Nobuko Yoshida. The presenters are Bernardo Toninho, Julien Lange and Raymond Hu. 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.

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle Scholar
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarCross RefCross Ref
  8. 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 ScholarGoogle ScholarCross RefCross Ref
  9. William R Cook. 1990. Object-oriented programming versus abstract data types. In Workshop of the REX Project (LNCS, Vol. 489 ). Springer, 151-178.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. Sophia Drossopoulou and Susan Eisenbach. 1997. Java is type safe-probably. In European Conference on Object-Oriented Programming. Springer, 389-418.Google ScholarGoogle ScholarCross RefCross Ref
  12. Jonas Duregård. 2016. Automating Black-Box Property Based Testing. Ph.D. Dissertation. Chalmers University of Technology.Google ScholarGoogle Scholar
  13. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. 1998. Classes and Mixins. In Principles of Programming Languages (POPL). 171-183.Google ScholarGoogle Scholar
  14. Matthew Fluet. 2015. MLton-Monomorphise. http://mlton.org/Monomorphise.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. Mark P Jones. 1995. Dictionary-free overloading by partial evaluation. Lisp and Symbolic Computation 8, 3 ( 1995 ), 229-248.Google ScholarGoogle Scholar
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarCross RefCross Ref
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. Maurice Naftalin and Philip Wadler. 2006. Java generics and collections. O'Reilly. http://www.oreilly.de/catalog/javagenerics/ index.htmlGoogle ScholarGoogle Scholar
  25. Tobias Nipkow and David von Oheimb. 1998. Javalight is Type-safe-Definitely. In Principles of Programming Languages (POPL). 161-170.Google ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle Scholar
  30. Bjarne Stroustrup. 2013. The C+ + Programming Language, 4th Edition. Addison-Wesley.Google ScholarGoogle Scholar
  31. Wouter Swierstra. 2008. Data types à la carte. Journal of Functional Programming 18, 4 ( 2008 ), 423-436.Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Don Syme. 1999. Proving Java Type Soundness. In Formal Syntax and Semantics of Java. Springer-Verlag, 83-118.Google ScholarGoogle Scholar
  33. 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 ScholarGoogle Scholar
  34. Ian Lance Taylor and Robert Griesemer. 2019. Contracts-Draft Design. https://go.googlesource.com/proposal/+/master/ design/go2draft-contracts.mdGoogle ScholarGoogle Scholar
  35. Ian Lance Taylor and Robert Griesemer. 2020. Type Parameters-Draft Design. https://go.googlesource.com/proposal/+/ refs/heads/master/design/go2draft-type-parameters.mdGoogle ScholarGoogle Scholar
  36. The Go Team. 2020. The Go Programming Language Specification. https://golang.org/ref/specGoogle ScholarGoogle Scholar
  37. The Rust Team. 2017. The Rust programming language. http://rust-lang.org/Google ScholarGoogle Scholar
  38. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  39. Mads Torgersen. 2004. The expression problem revisited. In European Conference on Object-Oriented Programming (ECOOP). Springer, 123-146.Google ScholarGoogle ScholarCross RefCross Ref
  40. Aaron Turon. 2015. Abstraction without overhead: traits in Rust. https://blog.rust-lang.org/ 2015 /05/11/traits.htmlGoogle ScholarGoogle Scholar
  41. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  42. Philip Wadler. 1998. The expression problem. Posted on the Java Genericity mailing list. http://homepages.inf.ed.ac.uk/ wadler/papers/expression/expression.txtGoogle ScholarGoogle Scholar
  43. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  44. Matthias Zenger and Martin Odersky. 2004. Independently extensible solutions to the expression problem. Technical Report.Google ScholarGoogle Scholar

Index Terms

  1. Featherweight go

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!