Abstract
In Java, lambda expressions (LEs) were introduced at a time where the similar language construct anonymous inner class (AIC) already existed for years. But while LEs became quite popular in mainstream programming languages in general, their usability is hardly studied. From the Java perspective the need to study the relationship between LEs and AICs was and is quite obvious, because both language constructs co-exist. However, it is quite usual that new language constructs are introduced although they are not or hardly studied using scientific methods – and an often heard argument from programming language designers is that the effort or the costs for the application of the scientific method on language constructs is too high. The present paper contributes in two different ways. First, with respect to LEs in comparison to AICs, this paper presents two N-of-1 studies (i.e. randomized control trials executed on a single subject) where LEs and AICs are used as listeners in Java code. Both experiments had two similar and rather simple tasks (“count the number of parameters”, respectively “count the number of used parameters”) with the dependent variable being reaction time. The first experiment used the number of parameters, the second the number of used parameters as the controlled, independent variable (in addition to the technique LE and AIC). Other variables (LOC, etc.) were randomly generated within given boundaries. The main result of both experiments is that LEs without type annotations require less reading time (p hs .2, reduction of reaction time of at most 35%). The results are based on 9,600 observations (one N-of-1 trial with eight replications). This gives evidence that the readability of LEs without type annotations improves the readability of code. However, the effect seems to be so small, that we do not expect this to have a larger impact on daily programming. Second, we see the contribution of this paper in the application of N-of-1 trials. Such experiments require relatively low effort in the data selection but still permit to analyze results in a non-subjective way using commonly accepted analysis techniques. Additionally, they permit to increase the number of selected data points in comparison to traditional multi–subject experiments. We think that researchers should take such experiments into account before planning and executing larger experiments.
Highlights
It is quite common that programming languages evolve over time by introducing new or changing existing language features
Our approach was to run an N-of-1 trial in order to study the readability of anonymous inner classes (AICs) and lambda expressions (LEs) in the programming language Java – for LEs we distinguished between those ones with type declaration (LET ) and those without (LENT )
This paper focuses on two topics: a technical topic and a methodological topic
Summary
It is quite common that programming languages evolve over time by introducing new or changing existing language features. While in some cases and for some languages the motivation for a new language feature might be the runtime performance of resulting programs or the provability of certain program characteristics (e.g. as motivation for type systems), most language features are probably introduced in order to improve development ergonomics, i.e. they focus on the readability, understandability, or writability of programs While topics such as readability and understandability are inherently humancentered topics, the number of human-centered studies in general is extremely low: according to a study by Kaijanaho This addition was guided by changes in the language API for graphical user interfaces, where the concept of listeners was applied – typically using anonymous inner classes An alternative to this kind of listener implementation emerged with Java 8 in 2013 (the language specification was published in 2014 (Gosling et al 2014)) where lambda expressions were introduced (a language construct that is well-known in functional programming). Java 8 introduced method references that permit to pass a named method as a parameter
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
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.