Abstract

It is generally considered that object-oriented (OO) languages provide weaker support for generic programming (GP) as compared with functional languages such as Haskell or SML. There were several comparative studies which showed this. But many new object-oriented languages have appeared in recent years. Have they improved the support for generic programming? And if not, is there a reason why OO languages yield to functional ones in this respect? In the earlier comparative studies object-oriented languages were usually not treated in any special way. However, the OO features affect language facilities for GP and a style people write generic programs in such languages. In this paper we compare ten modern object-oriented languages and language extensions with respect to their support for generic programming. It has been discovered that every of these languages strictly follows one of the two approaches to constraining type parameters. So the first design challenge we consider is “which approach is better”. It turns out that most of the explored OO languages use the less powerful one. The second thing that has a big impact on the expressive power of a programming language is language support for multiple models. We discuss pros and cons of this feature and its relation to other language facilities for generic programming.

Highlights

  • Almost all modern programming languages provide language support for generic programming (GP) [2]

  • We argue that OO languages are to be treated separately, because they support the distinctive OO features that pure functional languages do not, such as inheritance, interfaces/traits, subtype polymorphism, etc

  • We identify the dependencies between major language features, detect incompatible ones, and point the properties that a language design should satisfy to be effective for generic programming

Read more

Summary

Introduction

Almost all modern programming languages provide language support for generic programming (GP) [2]. There were several studies that compared language support for generic programming in different languages [3,4,5,6] These studies do not make any difference between object-oriented and functional languages. We argue that OO languages are to be treated separately, because they support the distinctive OO features that pure functional languages do not, such as inheritance, interfaces/traits, subtype polymorphism, etc These features affect the language design and a way people write generic programs in object-oriented languages. Several independent extensions have been developed for the mainstream OO languages [7,8,9,10] These new languages and extensions have many differences, but all of them tend to improve the support for generic programming. We identify the dependencies between major language features, detect incompatible ones, and point the properties that a language design should satisfy to be effective for generic programming

Main Ideas
Two Approaches to Constraining Type Parameters
Languages with “Constraints-are-Types” Philosophy
Interfaces in Ceylon and Kotlin
Scala Traits
Swift Protocols
Languages with “Constraints-are-Not-Types” Philosophy
JavaGI Generalized Interfaces
Which Philosophy Is Better If Any?
Single Model versus Multiple Models
Concept Pattern
Instance Uniqueness in Haskell
Parameters versus Predicates
Modular Implicits in OCaml
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.