An Empirical Study about the Use of Optional Typing in Software - - PowerPoint PPT Presentation

an empirical study about the use of optional typing in
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

An Empirical Study about the Use of Optional Typing in Software Systems

Carlos Souza

carlosgsouza@gmail.com

Eduardo Figueiredo

figueiredo@dcc.ufmg.br

slide-2
SLIDE 2

Java JavaScript

slide-3
SLIDE 3

dynamically

typed languages are becoming more popular

slide-4
SLIDE 4

15% 30%

slide-5
SLIDE 5

python python php php php python

ASP.net ASP.net

+javascript +javascript +javascript +javascript +javascript +javascript +javascript +javascript

slide-6
SLIDE 6

dynamically

typed languages are becoming more popular

slide-7
SLIDE 7

x Untyped

Typed

slide-8
SLIDE 8

What is the best type system?

slide-9
SLIDE 9

"If someone claims to have the perfect programming language, he is either a fool or a salesman or both."

(Bjarne Stroustrup)

slide-10
SLIDE 10

How do programmers use different typing paradigms?

slide-11
SLIDE 11

An Empirical Study about the Use of Optional Typing in Software Systems

Carlos Souza

carlosgsouza@gmail.com

Eduardo Figureido

figueiredo@dcc.ufmg.br

slide-12
SLIDE 12

Introduction Type Systems Study Settings Results and Discussion Conclusion and Future Work

slide-13
SLIDE 13

Introduction

Type Systems

Study Settings Results and Discussion Conclusion and Future Work

slide-14
SLIDE 14

Typed Untyped

slide-15
SLIDE 15

Typed

type checking documentation tool integration

String s = new File();

slide-16
SLIDE 16

Typed

type checking documentation tool integration

int sum(Integer[] list)

slide-17
SLIDE 17

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

  • bject of type Integer contains a single

field whose type is int.

slide-18
SLIDE 18

def sum(v) { def result v.each { result += it } return result }

Untyped

simplicity flexibility

slide-19
SLIDE 19

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"))

slide-20
SLIDE 20

Typed

type checking documentation tool integration

x

Untyped

simplicity flexibility

slide-21
SLIDE 21

How do programmers use different typing paradigms?

slide-22
SLIDE 22

Introduction Type Systems

Study Settings

Results and Discussion Conclusion and Future Work

slide-23
SLIDE 23

A large scale empirical study with the goal of finding how programmers use optional typing

slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26
slide-27
SLIDE 27
slide-28
SLIDE 28

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 }

slide-29
SLIDE 29

Where Groovy programmers like to

use types

and where they

don't

slide-30
SLIDE 30

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?

slide-31
SLIDE 31

Dataset

slide-32
SLIDE 32

projects declarations

  • f data

lines of code programmers

6638 1.5M 60GB 9.8M 4481

Dataset

slide-33
SLIDE 33

Dataset

slide-34
SLIDE 34

kind visibility context

typed or untyped Static code analyzer

slide-35
SLIDE 35

Dataset

?

Relative Use of Types

slide-36
SLIDE 36

Introduction Type Systems Study Settings

Results and Discussion

Conclusion and Future Work

slide-37
SLIDE 37

Do programmers use

types more often

in the interface of their modules?

Q1

slide-38
SLIDE 38

The interface of a module is composed by

fields, methods and constructors

which are

public or protected

slide-39
SLIDE 39

The interface of a module is NOT composed by

local variables

  • r

private declarations

slide-40
SLIDE 40

Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility

slide-41
SLIDE 41

Are these results

significantly

different?

slide-42
SLIDE 42

There is no difference in how programmers type different kinds of declarations

H0 :

slide-43
SLIDE 43

ANOVA Tukey Honestly Significant Differences

+

slide-44
SLIDE 44

α = 0.001

slide-45
SLIDE 45

confidence = 99.9%

slide-46
SLIDE 46

ANOVA reported

p = 0

slide-47
SLIDE 47
slide-48
SLIDE 48

Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility

slide-49
SLIDE 49
slide-50
SLIDE 50

Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility

slide-51
SLIDE 51

Yes,

programmers use

types more often

in the interface of their modules

Q1

slide-52
SLIDE 52
slide-53
SLIDE 53

programmers use types to document their modules

slide-54
SLIDE 54

documentation is not so necessary in local variables and private methods and fields

slide-55
SLIDE 55

Relative Usage of Types by Declaration Kind

Why are fields mostly untyped?

slide-56
SLIDE 56
slide-57
SLIDE 57

public protected private

slide-58
SLIDE 58

Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility

Why are constructor and protected declarations typed so often?

slide-59
SLIDE 59

constructors are important elements of a module definition

slide-60
SLIDE 60

protected declarations establish complex contracts

slide-61
SLIDE 61

Do programmers use

types less often

in test classes and scripts?

Q2

slide-62
SLIDE 62

Do programmers use

types less often

in test classes?

Q2.a

slide-63
SLIDE 63
slide-64
SLIDE 64

Factorial ANOVA Tukey Honestly Significant Differences

+

slide-65
SLIDE 65
slide-66
SLIDE 66
slide-67
SLIDE 67
slide-68
SLIDE 68
slide-69
SLIDE 69

Yes,

programmers use

types less often

in test classes

Q2.a

slide-70
SLIDE 70

Do programmers use

types less often

in scripts?

Q2.b

slide-71
SLIDE 71
slide-72
SLIDE 72

Yes,

programmers use

types less often

in scripts

Q2.b

slide-73
SLIDE 73

maintainability

is not a concern in these scenarios

slide-74
SLIDE 74

Does the

experience of programmers

with other languages influence their choice for typing their code?

Q3

slide-75
SLIDE 75

Static only Dynamic Only Static and Dynamic

slide-76
SLIDE 76
slide-77
SLIDE 77
slide-78
SLIDE 78

Yes,

programmers of the static only group use types more often than others

Q3

slide-79
SLIDE 79

programmers

get used

to the lack of types

slide-80
SLIDE 80

Does the

size, age or level of activity

  • f a project have any influence
  • n the usage of types?

Q4

slide-81
SLIDE 81

age (days) size (LoC) activity (commits)

Type Usage

Spearman Correlation Ranking

slide-82
SLIDE 82
slide-83
SLIDE 83

Do we see any influence on

mature projects?

slide-84
SLIDE 84

a project is considered mature if it has more than

100 days 2000 lines of code 100 commits

slide-85
SLIDE 85

we have

223

mature projects

slide-86
SLIDE 86
slide-87
SLIDE 87

ANOVA reported

p = 0.05

slide-88
SLIDE 88
slide-89
SLIDE 89

No,

the size, age and level of activity have no influence on the usage of types

Q4

slide-90
SLIDE 90

In frequently changed code, do developers prefer

typed or untyped

declarations?

Q5

slide-91
SLIDE 91

commits

  • f a file

Type Usage in that file

Spearman Correlation Ranking

slide-92
SLIDE 92

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

slide-93
SLIDE 93

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

slide-94
SLIDE 94

12% 30%

slide-95
SLIDE 95

In most cases, developers prefer

untyped declarations

in frequently changed code

Q5

slide-96
SLIDE 96

Introduction Type Systems Study Settings Results and Discussion

Conclusion and Future Work

slide-97
SLIDE 97

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

slide-98
SLIDE 98

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

slide-99
SLIDE 99

Future Work

slide-100
SLIDE 100

Measuring the impact of

compile, runtime and unit test

error messages on maintenance time

slide-101
SLIDE 101

ERA

An Elastic Framework for Repository Analysis

  • n the Cloud
slide-102
SLIDE 102

Groovonomics

Sharing the results with the Groovy community

slide-103
SLIDE 103

An Empirical Study about the Use of Optional Typing in Software Systems

Carlos Souza

carlosgsouza@gmail.com

Eduardo Figueiredo

figueiredo@dcc.ufmg.br

slide-104
SLIDE 104

github.com/carlosgsouza/groovonomics/

Carlos Souza

slide-105
SLIDE 105

github.com/carlosgsouza/groovonomics/