Ranjith Kumar Ramakrishnan, Jukka Lekkala · 2025
Programming languages evolve to meet technological advancements and developers' needs. This paper investigates the adoption of two significant Java features: Generics and Lambda Expressions. Prior research on Java Generics is replicated and extended, focusing on its usage across projects initiated before and after the release of Java SE 5.0. The findings reveal whether newer projects are embracing Generics more comprehensively than older ones. Additionally, the adoption of Lambda Expressions, introduced in Java SE 8, is examined to assess their impact on code simplicity and refactoring. By analyzing a dataset of opensource projects, the study evaluates the prevalence and effectiveness of these features in practice. The results highlight key trends and provide insights into the practical application of these language constructs in contemporary Java development.
Cited by 0Open access
Robert Griesemer, Raymond Hu, Wen Kokke et al. · Proceedings of the ACM on Programming Languages · 2020
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.
Cited by 17Open access
Nicholas Cameron, James Noble · 2012
Ownership types structure the heap, and can enforce encapsulation properties which improve security, provide more information for the programmer, and allow for better reasoning about programs. Ownership Generic Java (OGJ) implements ownership types using Java generics and some additional type checking. This allows the programmer to use generics and ownership types in the same programs with little addtional syntactic overhead. We combine Java wildcards (represented formally as existential types) with OGJ to enforce an ownership topology using only features of the Java type system. We demonstrate how the owners-as-dominators encapsulation property can be enforced by a minimal addition to the well-formedness rules for types and classes. We show that the type parameterisation of Java generics — with wildcards — is sufficient to enforce ownership. 1.
Cited by 0
Sukhachev, Anton · Zenodo (CERN European Organization for Nuclear Research) · 2022
This article explains the main ways to implement generics in programming languages, using simple PHP, Hack, Java, and C++ examples. It describes three common approaches - type erasure, reification, and monomorphization - and compares how they handle type checking and reflection during static analysis, compile time, and runtime. The article also provides visibility tables to show what type information is available in each stage. Real examples demonstrate how Java uses type erasure, Hack supports reified generics, and C++ templates represent monomorphization. The author also introduces a PHP library that brings monomorphic generics to PHP.
Cited by 0Open access
Sukhachev, Anton · Zenodo (CERN European Organization for Nuclear Research) · 2022
This article explains the main ways to implement generics in programming languages, using simple PHP, Hack, Java, and C++ examples. It describes three common approaches - type erasure, reification, and monomorphization - and compares how they handle type checking and reflection during static analysis, compile time, and runtime. The article also provides visibility tables to show what type information is available in each stage. Real examples demonstrate how Java uses type erasure, Hack supports reified generics, and C++ templates represent monomorphization. The author also introduces a PHP library that brings monomorphic generics to PHP.
Cited by 0Open access
Nick Cameron, Supervised Sophia Drossopoulou, Nobuko Yoshida · 2007
Wildcards are used in Java to soften the mismatch between parametric polymorphism (generics) and subtype polymorphism (inheritance). Java with wildcards has not been proven type sound (unlike generics) and so may include security holes that could affect nearly every program written in Java in the last few years (since wildcards are used extensively throughout the Java libraries). The bulk of this report describes formalising wildcards with the intent of proving type soundness. The remainder of this report deals with ongoing research into virtual classes. Virtual classes are an object-oriented mechanism for improving re-use and extensibility. Virtual classes are closely related to virtual types, which are an alternative mechanism for providing parametric polymorphism in object-oriented languages. Unlike generics, some measure of subtype variance comes ‘as standard ’ with virtual types. However, combining parametric types with virtual classes has not been well studied.
Cited by 0
Maurizio Cimadamore, Mirko Viroli · 2007
Providing runtime information about generic types---that is, reifying generics---is a challenging problem studied in several research papers in the last years. However, the quest for finding effective and efficient solutions specifically targeted to the Java programming language is still open. In particular, the new mechanism of wildcards introduced in Java 5.0 significantly complicates the overall semantics of generics: its reification aspects are currently unexplored and pose serious implementation issues.
Cited by 4
Nick Cameron, Erik Ernst, Sophia Drossopoulou · 2008
Abstract. Wildcards extend Java generics by softening the mismatch between subtype and parametric polymorphism. Although they are a key part of the Java 5.0 programming language, a type system including wildcards has never been proven type sound. Wildcards have previously been formalised as existential types. In this paper we extend FGJ, a featherweight formalisation of Java with generics, with existential types. We prove that this calculus, ∃J, is type sound, and illustrate how it models wildcards in the Java Programming Language. ∃J is not a full model for Java wildcards, because it does not support lower bounds for wildcards. We discuss why ∃J can not be easily extended with lower bounds, and how full Java wildcards could be modelled in a type sound way. 1
Cited by 0
Cameron, Nicholas, Drossopoulou, Sophia, Ernst, Erik · 2007
Wildcards extend Java generics by softening the mismatch between subtype and parametric polymorphism. Although they are a key part of the Java 5.0 programming language, a type system including wildcards has never been proven type sound. Wildcards have previously been formalised as existential types. In this paper we extend FGJ, a featherweight formalisation of Java with generics, with existential types.<br/>We prove that this calculus, ExistsJ, is type sound, and illustrate how it models wildcards in the Java Programming Language. ExistsJ is not a full model for Java wildcards, because it does not support lower bounds for wildcards. We discuss why ExistsJ can not be easily extended with lower bounds, and how full Java wildcards could be modelled in a type sound way.
Cited by 4
Laurentiu Dragan, et al. · 2005
This paper studies the performance of generics, or templates as they are sometimes called, for scientific computing in various programming languages. In order to understand the cost of using generics, we develop a test suite for generics based on a standard numeric benchmark. We compare the results of this new benchmark for generics in C++, C# and Java, both between language implementations and against the specialized, non-generic benchmark. We also compare the efficiency of C++ with Aldor, a language originally for computer algebra relying entirely on generics. We find that the implementation of generics in current compilers must be improved before they are used for efficiencycritical scientific applications, and we identify specific areas for potential optimization.
Cited by 0
Gerlach, J., Kneis, J. · Publikationsdatenbank der Fraunhofer-Gesellschaft (Fraunhofer-Gesellschaft) · 2003
Parameterized types (generics) have been announced for the Java(TM) and C# programming languages. In this paper, we evaluate these extensions with respect to the realm of scientific computing and compare them with C++ templates. At the heart of our comparison are the set and relation classes from the Janus framework which provides abstraction for the efficient representation of meshes, sparse graphs and associated matrices. As an example, we compare the performance of the Bellman-Ford single source shortest path algorithm when using parameterized Janus data structures implemented in C++, Java(TM), and C#. Our measurements suggest that both Java(TM) and C# generics introduce only little run time overhead when compared with non-parameterized implementations. With respect to scientific application, C# generics have the advantage of allowing value types (including builtin types) as parameters of generic classes and methods.
Cited by 1
Janusz Jabłonowski · 2008
Abstract: Generics allow programmers to write more abstract code, which is- to some degree-independent from the types involved in the underlying algorithm. For example the code handling stack operations does not depend on the type of stack elements. Many languages support the notion of generics (for example templates in C++ allow writing generic code). Recently generics have been added to the Java programming language and the standardizing committee for the C # programming language is working on the second version of C#, which includes generics. Also beta releases of the new Visual Studio environment are accessible, which include generics support. In this paper we describe our experiences from the work with generics in C#. Key words: Programming Languages, Object-Oriented Programming, Generic types.
Cited by 0
Adam Kie un, Robert M. Fuhrer, Frank Tip et al. · 2005
We present refactorings that automate the process of migrating pre-generics Java programs to use generics. The task is divided in two parts: introduction of formal type parameters (parameterization) and inference of actual type parameters (instantiation). We developed efficient techniques and tools to assist developers in both parts. We will present them during the demonstration.
Cited by 3
Pavel ŘÍHA · Digital Repository (National Repository of Grey Literature) · 2009
This diploma introduces for readers Java generics with using examples and discuses its uses in real and most common problems. Work includes examples of using the Java libraries in JDK, as well as own examples of declaration of generic classes and methods.
Cited by 0
Liguori, Robert, Liguori, Patricia · CERN Document Server (European Organization for Nuclear Research) · 2009
How many times have you reached an impasse while writing code because you couldn't remember how something in Java worked? This new pocket guide is designed to keep you moving. Java Pocket Guide contains everything you really need to know about Java, particularly the new areas in Java 5 and 6, such as generics and annotations. It's the only book on Java that you can actually fit in your pocket.
Cited by 0
James Sasitorn, Robert Cartwright · 2007
This technical report presents a type soundness proof for Core CGen, a small, formal language designed for studying the addition of a component system based on genericity to a nominally typed objectoriented language supporting first-class generics. Core CGen captures the most intricate aspects of the Component NextGen programming language, an extension of the NextGen architecture that provides efficient support for first-class generics in Java, and maintains full compatibility with existing Java Virtual Machines. We begin by reviewing the semantics of Core CGen, and the proceed by establishing several key lemmas. Finally, we conclude by establishing preservation and progress theorems. 1
Cited by 0
Laurentiu Dragan, Stephen M. Watt · 2006
With the introduction of support for generics in mainstream programming languages, we see an renewed interest in writing generic code. Maple offers the possibility to write generic code using module-producing functions. There is usually a performance cost associated with the use of generics, and this paper analyzes the cost of using these in Maple. We created sets of tests for different styles of generics and compared their performance with specialized Maple code. The first set of tests implemented generics in the style of parameterized abstract data types, with Maple modules providing functions that operated on data values. The second set of tests implemented generics in the style of parameterized object-oriented classes, where each data value was embodied in its own module object. The test functions were based on the popular SciMark benchmark for scientific computation in Java. The results show a small degradation of performance when using generics modeled on abstract data types and high performance degradation when using an object-oriented approach. Keywords. generics, parametric polymorphism, performance, Maple. 1
Cited by 0
Mukherjee, Sudipta · CERN Document Server (European Organization for Nuclear Research) · 2012
This is a concise, practical guide that will help you learn Generics in .NET, with lots of real world and fun-to-build examples and clear explanations. It is packed with screenshots to aid your understanding of the process. This book is aimed at beginners in Generics. It assumes some working knowledge of C# , but it isn't mandatory. The following would get the most use out of the book: Newbie C# developers struggling with Generics. Experienced C++ and Java Programmers who are migrating to C# and looking for an alternative to other generic frameworks like STL and JCF would find this book handy.
Cited by 0
ourmedia@rudiment.net · Bulletin of Miscellaneous Information (Royal Gardens Kew)
In this episode, Ted and Craig interview their old colleague Eric about the crazy stuff he's doing in Java with generics and reflection. This one is very tech heavy; you've been warned.
Cited by 0
Ronald Garcia, Jaakko Järvi, Andrew Lumsdaine et al. · ACM SIGPLAN Notices · 2003
Many modern programming languages support basic generic programming, sufficient to implement type-safe polymorphic containers. Some languages have moved beyond this basic support to a broader, more powerful interpretation of generic programming, and their extensions have proven valuable in practice. This paper reports on a comprehensive comparison of generics in six programming languages: C++, Standard ML, Haskell, Eiffel, Java (with its proposed generics extension), and Generic C. By implementing a substantial example in each of these languages, we identify eight language features that support this broader view of generic programming. We find these features are necessary to avoid awkward designs, poor maintainability, unnecessary run-time checks, and painfully verbose code. As languages increasingly support generics, it is important that language designers understand the features necessary to provide powerful generics and that their absence causes serious difficulties for programmers.
Cited by 17