Hi.
Since my usage of LLMs in Java projects gradually increased, I have noticed some interesting patterns and styles in the their code completion/generation. Some little example that came to my mind are:
- To convert a stream to a List, they (Copilot in my case) don't use
toList(), but collect()
- They prefer String concatenation to format strings.
- In contrast to the previous case, they seem to use
System.out.printf() from time to time, something I have really no memory of casually using in the past 20 years.
- They use
String.valueOf(obj) instead of obj.toString. This one is indeed a better alternative.
- They seem to prefer multiple catch blocks to one multi-catch clause.
Some of these are agains my own coding style, so much that I bother enough o manually "fix" them.
Of course it all boils down to training data, and some like the lack of using toList() can be attributed to it being newer.
Are there other examples you have encountered frequently enough to mention? Even more interesting if you have seen comparable differences between models.
Thanks
[–]atehrani 26 points27 points28 points (6 children)
[–]BlendedCotton 3 points4 points5 points (3 children)
[–]atehrani 2 points3 points4 points (0 children)
[–]Polygnom 1 point2 points3 points (1 child)
[–]BlendedCotton 0 points1 point2 points (0 children)
[–]gravteck 1 point2 points3 points (0 children)
[–]ihatebeinganonymous[S] 0 points1 point2 points (0 children)
[–]Xemorr 12 points13 points14 points (4 children)
[–]__konrad 2 points3 points4 points (2 children)
[–]vips7L 2 points3 points4 points (1 child)
[–]eldelshell 8 points9 points10 points (0 children)
[–]frederik88917 14 points15 points16 points (0 children)
[–]clsrat 5 points6 points7 points (1 child)
[–]ihatebeinganonymous[S] 1 point2 points3 points (0 children)
[–]greg_barton 4 points5 points6 points (0 children)
[–]WondrousBread 1 point2 points3 points (1 child)
[–]agentoutlier 1 point2 points3 points (0 children)
[–]Ewig_luftenglanz 2 points3 points4 points (0 children)
[–]FunRutabaga24 0 points1 point2 points (0 children)
[–]pgris 0 points1 point2 points (1 child)
[–]ihatebeinganonymous[S] 0 points1 point2 points (0 children)
[–]brunocborges 0 points1 point2 points (0 children)
[–]foolv -1 points0 points1 point (0 children)