⬆️ ⬇️

What styles of code design does the Gietgab audience prefer?

Spaces or tabs? Double or single quotes? Open curly braces with a new line or in the "Egyptian" style? Sacred wars are constantly raging around these source design agreements. However, few people decide to argue with the fact that if you work in a team, you must write as it is accepted in this team, or at least reformat your code in the accepted style before the commit. In the end, if some style had an absolutely decisive advantage over another, then there would have been no disputes, so perhaps the wisest decision is to do everything.







And how do they do everything? The sideeffect.kr website collected statistics on Github commits for several months for the languages ​​JavaScript, Ruby, Scala, C #, Java and Python. For each language, several typical differences in the design of the code are highlighted, and it is calculated which variant the community is inclined to.



In the most popular holivar “spaces against tabulation”, a decisive victory was gained by spaces. Most of all tabbing fans remain in the Java camp - 24.6%. Least of all - among Scala programmers - 3.3%. But in some other matters there is no unanimity. So, those who like to use upper case for naming constants in Java are only 3% more than half, and those who write in C # use three different styles for constants (caps, Pascal-style and how-to) with almost equal frequency. Supporters of double and single quotes in JavaScript are almost equally divided.

')

Some conventions are opposite for different languages. So, the vast majority (86%) of C # programmers open a curly bracket on a new line. In Java, the opposite is true - only 19.8% adhere to such an agreement. The rest use the "Egyptian" style.



This project was created for the GitHub Data Challenge II contest for analyzing and visualizing GitHub open data, its code is published on Github under the MIT license, so you can add new languages ​​and new code design agreements there.



Source: https://habr.com/ru/post/201544/



All Articles