an empirical study about the use of optional typing in
play

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


  1. An Empirical Study about the Use of Optional Typing in Software Systems Carlos Souza Eduardo Figueiredo carlosgsouza@gmail.com figueiredo@dcc.ufmg.br

  2. Java JavaScript

  3. dynamically typed languages are becoming more popular

  4. 30% 15%

  5. python php python php +javascript +javascript +javascript +javascript php python ASP.net ASP.net +javascript +javascript +javascript +javascript

  6. dynamically typed languages are becoming more popular

  7. x Untyped Typed

  8. What is the best type system?

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

  10. How do programmers use different typing paradigms?

  11. An Empirical Study about the Use of Optional Typing in Software Systems Carlos Souza Eduardo Figureido carlosgsouza@gmail.com figueiredo@dcc.ufmg.br

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

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

  14. Typed Untyped

  15. Typed type checking String s = new File(); documentation tool integration

  16. Typed type checking documentation int sum(Integer[] list) tool integration

  17. Typed public final class Integer extends Number type checking implements Comparable<Integer> The Integer class wraps a value of the primitive type int in an object. An documentation object of type Integer contains a single field whose type is int. tool integration int sum(Integer[] list)

  18. Untyped def sum(v) { def result v.each { simplicity result += it } return result flexibility }

  19. Untyped simplicity def byteValue(number) { return number.byteValue() flexibility } ... println byteValue(new Integer (1)) println byteValue(new Double (1.0)) println byteValue(new CarlosInt ("1"))

  20. Typed Untyped x type checking simplicity documentation flexibility tool integration

  21. How do programmers use different typing paradigms?

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

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

  24. int sum(int a, int b) def sum(a,b) { { int result = a+b def result = a+b return result return result } } int sum(a, int b) { def result = a+b return result }

  25. Where Groovy programmers like to use types and where they don't

  26. 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?

  27. Dataset

  28. Dataset 6638 projects 1.5M declarations 60GB of data 9.8M lines of code 4481 programmers

  29. Dataset

  30. Static code analyzer kind visibility context typed or untyped

  31. Dataset Relative ? Use of Types

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

  33. Q1 Do programmers use types more often in the interface of their modules ?

  34. The interface of a module is composed by fields, methods and constructors which are public or protected

  35. The interface of a module is NOT composed by local variables or private declarations

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

  37. Are these results significantly different?

  38. There is no difference H 0 : in how programmers type different kinds of declarations

  39. ANOVA + Tukey Honestly Significant Differences

  40. α = 0.001

  41. confidence = 99.9%

  42. ANOVA reported p = 0

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

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

  45. Q1 Yes , programmers use types more often in the interface of their modules

  46. programmers use types to document their modules

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

  48. Why are fields mostly untyped? Relative Usage of Types by Declaration Kind

  49. private protected public

  50. Why are constructor and protected declarations typed so often? Relative Usage of Types by Declaration Kind Relative Usage of Types by Declaration Visibility

  51. constructors are important elements of a module definition

  52. protected declarations establish complex contracts

  53. Q2 Do programmers use types less often in test classes and scripts?

  54. Q2.a Do programmers use types less often in test classes?

  55. Factorial ANOVA + Tukey Honestly Significant Differences

  56. Q2.a Yes , programmers use types less often in test classes

  57. Q2.b Do programmers use types less often in scripts?

  58. Q2.b Yes , programmers use types less often in scripts

  59. maintainability is not a concern in these scenarios

  60. Q3 Does the experience of programmers with other languages influence their choice for typing their code?

  61. Static only Dynamic Only Static and Dynamic

  62. Q3 Yes , programmers of the static only group use types more often than others

  63. programmers get used to the lack of types

  64. Q4 Does the size, age or level of activity of a project have any influence on the usage of types?

  65. Spearman Correlation Ranking Type age (days) size (LoC) Usage activity (commits)

  66. Do we see any influence on mature projects?

  67. a project is considered mature if it has more than 100 days 2000 lines of code 100 commits

  68. we have 223 mature projects

  69. ANOVA reported p = 0.05

  70. Q4 No , the size, age and level of activity have no influence on the usage of types

  71. Q5 In frequently changed code, do developers prefer typed or untyped declarations?

  72. Spearman Correlation Ranking Type commits Usage in of a file that file

  73. Type File Commits Usage Car.groovy 10 0.1 Wheel.groovy 15 0.2 Engine.groovy 16 0.21 Transmission.groovy 17 0.23 Radio.groovy 38 0.44 Spearman Ranking = 1.0

  74. Type File Commits Usage Car.groovy 10 0.9 Wheel.groovy 15 0.82 Engine.groovy 16 0.21 Transmission.groovy 17 0.14 Radio.groovy 38 0.04 Spearman Ranking = -1.0

  75. 12% 30%

  76. Q5 In most cases, developers prefer untyped declarations in frequently changed code

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

  78. 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

  79. 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

  80. Future Work

  81. Measuring the impact of compile, runtime and unit test error messages on maintenance time

Recommend


More recommend