Java Generics Adoption: How New Features are Introduced Championed or Ignored

979 views

Published on

Adding features to a programming language is a difficult prospect. Politics, committees, compatibility, and egos don’t make it any easier. And once a feature has finally made it and shipped, there is a whole other question of how does it plays out? Did designers get it right, does adoption occur? Does the promises of the new feature actually solve the software developer’s pain? How do developers decide to use a new feature, do they plan to migrate old code, coordinate coding standards?

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
979
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Casts: ugly and runtime exception
  • TODO: move “myList” decl so transition smoother
  • So what happened with generics? To find out why, let’s start at the beginnning…
  • So to investigate what happened to generics, let’s look at the claims and complaints made about generics
  • TODO mention why we think they’re true (repeatedly!)
  • Emphasize historical lookSimplify process diagram
  • Zoom size of each person for contribution amount.Put research question on topFor each question, remind what answer is
  • Some developers stubbornly used “raw” types despite adoption by others in the same project, whereas, in many projects that did use generics, there was a single developer who “championed” the use of generics, by using generics much earlier and in larger amounts than other developers.
  • Casts reduced before developers start to introduce generics.Spearman rank correlation:Only squirrel-sql had a strong correlation6 with moderate correlation.Gradual reveal, starting with one project, starting with 1 lineChange colors to be consistentMention normalization partBe sure to point out parts of graph that support what you say
  • Casts reduced before developers start to introduce generics.Spearman rank correlation:Only squirrel-sql had a strong correlation6 with moderate correlation.Gradual reveal, starting with one project, starting with 1 lineChange colors to be consistentMention normalization partBe sure to point out parts of graph that support what you say
  • Prematuregenerification.
  • Clean up, make as conclusion slide
  • Java Generics Adoption: How New Features are Introduced Championed or Ignored

    1. 1. Java Generics Adoption<br />How New Features are Introduced, Championed, or Ignored<br />Chris Parnin<br /> Georgia Tech<br />Christian Bird<br />Microsoft Research<br />Emerson Murphy-Hill<br />North Carolina State<br />
    2. 2. Quick refresher<br />Raw Type R<br />List myList= …;<br />String aStringFromMyList = (String)myList.get(0);<br />class List{<br /> Object get(int i){…}<br />}<br />Cast (C)<br />
    3. 3. Quick refresher<br />List myList = …;<br />String aStringFromMyList = (String)myList.get(0);<br />class List<T>{<br /> T get(int i){…}<br />}<br />Generic Type <T><br />
    4. 4. Quick refresher<br />Parameterized Type <P><br />List<String> myList= …;<br />String aStringFromMyList = myList.get(0);<br />class List<T>{<br /> T get(int i){…}<br />}<br />static <T> T head(List<T> l){<br /> return l.get(0);<br />};<br />Generic Method <M><br />
    5. 5. but life is not so simple…<br />
    6. 6. public interface Identifiable<T extends Identifier<? extends What>, What> {<br /> public TgetObjectID();<br /> public Class<? super What> type();<br />}<br />public interface Identifier<T> {<br /> public long getID();<br /> public Class<? super T> type();<br />}<br />interface X <SubjectType extends Identifiable, RelationshipType extends<br />Enum<RelationshipType> & Related, ObjectType extends Identifiable>{}<br /> <br />static class A<<br /> SI extends Identifier<? extends SubjectType>,<br /> OI extends Identifier<? extends ObjectType>,<br />SubjectType extends Identifiable<SI, SubjectType>,<br />RelationshipType extends Enum<RelationshipType> & Related,<br />ObjectType extends Identifiable<? extends OI, ? extends ObjectType>><br /> implements<br /> X<SubjectType, RelationshipType, ObjectType> {<br />}<br />
    7. 7. public interface Identifiable<T extends Identifier<? extends What>, What> {<br /> public TgetObjectID();<br /> public Class<? super What> type();<br />}<br />public interface Identifier<T> {<br /> public long getID();<br /> public Class<? super T> type();<br />}<br />interface X <SubjectType extends Identifiable, RelationshipType extends<br />Enum<RelationshipType> & Related, ObjectType extends Identifiable>{}<br /> <br />static class A<<br /> SI extends Identifier<? extends SubjectType>,<br /> OI extends Identifier<? extends ObjectType>,<br />SubjectType extends Identifiable<SI, SubjectType>,<br />RelationshipType extends Enum<RelationshipType> & Related,<br />ObjectType extends Identifiable<? extends OI, ? extends ObjectType>><br /> implements<br /> X<SubjectType, RelationshipType, ObjectType> {<br />}<br />“As I sit and stare in stunned <br />horror at this monster”<br />"Writing generified classes is rocket science"<br />“Probably more time and brainpower was spent <br />fussing with generics than any other single thing” <br />
    8. 8. why are these people so angry?<br />As a community, we often don’t formally evaluate our claims after we put them out into the world.<br />
    9. 9. Outcome<br />?<br />Gosling<br />Idea<br />Guy Steele Debate<br />Java 5<br />Implement and Release<br />Developer Usage<br />1994<br />1998<br />2004<br />2011<br />
    10. 10. To investigate what happened to generics, <br />let’s look at the claims and complaints made<br />about generics<br />
    11. 11. “I suspect we will see a lot of Java 5 code that continues to do things the bad old way as a result and contend with the mish-mash that results” (2005) <br />– lambda the ultimate<br />Did programmers adopt and use generics?<br />
    12. 12. “There seems to be some debateover refactoring to utilize java generics within my current team … a holy war going on about what should and should not be done …” – stackoverflow<br />Did programmers adopt and use generics?<br />Will teammates all agree to use generics?<br />
    13. 13. “Do you want to go back to casting-from-Object in every container access and dealing with the resulting runtime-revealed type errors?” – stackoverflow<br />ClassCastExceptionsare rarely seen in bug reports!<br />Caught with local testing before check-ins, etc…<br />Did programmers adopt and use generics?<br />Will teammates all agree to use generics?<br />Does generics reduce runtime errors?<br />Does generics reduce casts?<br />
    14. 14. RQ 1 Adoption<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />Did programmers adopt and use generics?<br />Will teammates all agree to use generics?<br />Does generics reduce casts?<br />
    15. 15. Study Setup<br />RQ 1 Adoption<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />Lifetime of 20 open-source projects: Before and After generics.<br /><P><M>(C)<T>R<br />500 million LOC<br />Entities of Interest Per Commit<br />Database for Analysis<br />
    16. 16. 532 developer’s generic usage?<br />RQ 1 Adoption<br />We use generic collections!<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />We use generics methods or classes!<br />No generics!<br />
    17. 17. Developers with higher commit frequency?<br />RQ 1 Adoption<br />Higher ratio of generics collection usage (42%)<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />But generic methods or classes stay about the same.<br />
    18. 18. RQ 1 Adoption<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />Never used generics<br />
    19. 19. RQ 1 Adoption<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />Another programmer starts contributing…<br />Then a champion emerges!<br />Then others follow.<br />The champion even migrates old code. <br />
    20. 20. RQ 1 Adoption<br />RQ 2<br />Coordination<br />jEdit<br />RQ 3<br />Casts<br />Casts (normalized) should decrease with generics.<br />(C)<br />We found no correlationfor jEdit<br /><P><br />
    21. 21. RQ 1 Adoption<br />RQ 2<br />Coordination<br />jEdit<br />RQ 3<br />Casts<br />Squirrel-SQL<br />Casts reduced before developers start to introduce generics.<br />(C)<br />(C)<br /><P><br />We found a strong correlationfor Squirrel-SQL<br /><P><br />
    22. 22. RQ 1 Adoption<br />RQ 2<br />Coordination<br />RQ 3<br />Casts<br />But, overall, only Squirrel-SQL had a strong correlation, and <br />6 with moderate correlation.<br />
    23. 23. Other findings<br />Very little refactoring to generics (typically under 10%)<br />Half of generics instantiated with just one type<br />Generics support modest reductions in duplication<br />90% of generic usage is java.util collections<br />IDE support has little relation to generic adoption date<br />Generic methods are rare!<br />
    24. 24. A Metaphor<br />Regulates Drugs<br />Regulates Programming Features<br />Monitors Adverse Reactions<br />Monitors Allergic Reactions<br />Measures treatment effectiveness<br />Measures impact and migration costs<br />

    ×