An Empirical Study about the Use of Optional Typing in Software Systems
Carlos Souza
carlosgsouza@gmail.com
Eduardo Figueiredo
figueiredo@dcc.ufmg.br
An Empirical Study about the Use of Optional Typing in Software - - PowerPoint PPT Presentation
An Empirical Study about the Use of Optional Typing in Software Systems Carlos Souza Eduardo Figueiredo carlosgsouza@gmail.com figueiredo@dcc.ufmg.br Java JavaScript dynamically typed languages are becoming more popular 30% 15% python
An Empirical Study about the Use of Optional Typing in Software Systems
Carlos Souza
carlosgsouza@gmail.com
Eduardo Figueiredo
figueiredo@dcc.ufmg.br
Java JavaScript
15% 30%
python python php php php python
ASP.net ASP.net
+javascript +javascript +javascript +javascript +javascript +javascript +javascript +javascript
"If someone claims to have the perfect programming language, he is either a fool or a salesman or both."
(Bjarne Stroustrup)
How do programmers use different typing paradigms?
An Empirical Study about the Use of Optional Typing in Software Systems
Carlos Souza
carlosgsouza@gmail.com
Eduardo Figureido
figueiredo@dcc.ufmg.br
Introduction Type Systems Study Settings Results and Discussion Conclusion and Future Work
Introduction
Study Settings Results and Discussion Conclusion and Future Work
Typed
type checking documentation tool integration
String s = new File();
Typed
type checking documentation tool integration
int sum(Integer[] list)
Typed
type checking documentation tool integration
int sum(Integer[] list)
public final class Integer extends Number implements Comparable<Integer>
The Integer class wraps a value of the primitive type int in an object. An
field whose type is int.
def sum(v) { def result v.each { result += it } return result }
Untyped
simplicity flexibility
Untyped
simplicity flexibility
def byteValue(number) { return number.byteValue() } ... println byteValue(new Integer(1)) println byteValue(new Double(1.0)) println byteValue(new CarlosInt("1"))
Typed
type checking documentation tool integration
Untyped
simplicity flexibility
How do programmers use different typing paradigms?
Introduction Type Systems
Results and Discussion Conclusion and Future Work
A large scale empirical study with the goal of finding how programmers use optional typing
int sum(int a, int b) { int result = a+b return result } def sum(a,b) { def result = a+b return result } int sum(a, int b) { def result = a+b return result }
Where Groovy programmers like to
and where they
Q1: Do programmers use types more often
in the interface of their modules?
Q2: Do programmers use types less often
in test classes and scripts?
Q3: Does the experience of programmers with other
languages influence their choice for typing their code?
Q4: Does the size, age or level of activity of a
project have any influence on the usage of types?
Q5: In frequently changed code, do developers
prefer typed or untyped declarations?
Dataset
projects declarations
lines of code programmers
Dataset
Dataset
kind visibility context
typed or untyped Static code analyzer
Dataset
?
Relative Use of Types
Introduction Type Systems Study Settings
Conclusion and Future Work
Do programmers use
types more often
in the interface of their modules?
The interface of a module is composed by
fields, methods and constructors
which are
public or protected
The interface of a module is NOT composed by
local variables
private declarations
Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility
There is no difference in how programmers type different kinds of declarations
ANOVA Tukey Honestly Significant Differences
confidence = 99.9%
ANOVA reported
Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility
Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility
programmers use
types more often
in the interface of their modules
programmers use types to document their modules
documentation is not so necessary in local variables and private methods and fields
Relative Usage of Types by Declaration Kind
Why are fields mostly untyped?
public protected private
Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility
Why are constructor and protected declarations typed so often?
constructors are important elements of a module definition
protected declarations establish complex contracts
Do programmers use
types less often
in test classes and scripts?
Do programmers use
types less often
in test classes?
Factorial ANOVA Tukey Honestly Significant Differences
programmers use
types less often
in test classes
Do programmers use
types less often
in scripts?
programmers use
types less often
in scripts
is not a concern in these scenarios
Does the
experience of programmers
with other languages influence their choice for typing their code?
Static only Dynamic Only Static and Dynamic
programmers of the static only group use types more often than others
programmers
to the lack of types
Does the
size, age or level of activity
age (days) size (LoC) activity (commits)
Type Usage
Spearman Correlation Ranking
Do we see any influence on
a project is considered mature if it has more than
100 days 2000 lines of code 100 commits
ANOVA reported
the size, age and level of activity have no influence on the usage of types
In frequently changed code, do developers prefer
typed or untyped
declarations?
commits
Type Usage in that file
Spearman Correlation Ranking
Car.groovy Wheel.groovy Engine.groovy Transmission.groovy Radio.groovy 10 15 16 17 38 0.1 0.2 0.21 0.23 0.44 File Commits Type Usage Spearman Ranking = 1.0
Car.groovy Wheel.groovy Engine.groovy Transmission.groovy Radio.groovy 10 15 16 17 38 0.9 0.82 0.21 0.14 0.04 File Commits Type Usage Spearman Ranking = -1.0
12% 30%
In most cases, developers prefer
untyped declarations
in frequently changed code
Introduction Type Systems Study Settings Results and Discussion
Conclusion and Future Work
Groovy programmers types more often in declarations that define the interface of modules
Types are used less frequently
in test classes and script files Programmer’s who only developed in statically typed languages type more often than other programmers There is no influence of the size, age or level of activity of a project on how programmers use types In frequently changed files,
untyped declarations are more popular
Provides real data which can be used by developers of programming languages and tools Helps on the understanding of the tradeoffs between different typing paradigms Complements experimental studies with a different point of view Raises new questions that can inspire other researchers
Future Work
Measuring the impact of
compile, runtime and unit test
error messages on maintenance time
An Elastic Framework for Repository Analysis
Sharing the results with the Groovy community
An Empirical Study about the Use of Optional Typing in Software Systems
Carlos Souza
carlosgsouza@gmail.com
Eduardo Figueiredo
figueiredo@dcc.ufmg.br
github.com/carlosgsouza/groovonomics/
Carlos Souza
github.com/carlosgsouza/groovonomics/