kotlin-web-site
kotlin-web-site copied to clipboard
Update Coding Conventions to match Compose conventions
While discussing on Slack, there was an overall consensus that the current SCREAMING_SNAKE_CASE
convention is inconsistent for a few reasons:
- It shouts at the readers and calls their attention first thing for things that shouldn't get more attention than other parts of the code. Enums, singletons, and constants do not hold any special characteristic that would require the reader to inspect the value of the variable or where it's being used. They don't represent unsafe, sensitive, or experimental code*.
- Compose, along with most of their plugins, libraries, and extensions, use the
PascalCase
convention. They have their own convention and reasoning for it written down here.- Given that Compose is one of the most-used frameworks, it fragments the community towards either their or Kotlin's official convention, which is bad.
- Having either
PascalCase
andSCREAMING_SNAKE_CASE
allowed for enums isn't a good convention because it allows developers to make individual decisions on which style to pick and leads the project to a mixed (or no?) convention (Ktor's public enums are an example), defeating the purpose of a convention, which is to standardize the way developers write code and eliminate bike-shedding.
Given that Kotlin 2.0 is about to be released, this is the perfect time to make this change, and the community, as well as some JetBrains team members, have voted in favor of this change. I will be linking the PR on the Slack thread so the community and the Kotlin team are up-to-date and can add feedback.
* On a side note, the current convention is likely inherited from Java, which in turn inherited it from the C/C++ convention for macros, as they were used for constants. However, macros indeed require more attention because of arbitrary code expansion, so the shouting makes sense.