7 ms·
The capitalisation issue is the sort of thing you'd tell a junior developer to avoid in code review: By tying one design decision (what access levels are possib
by pdpi 9y ago
The capitalisation issue is the sort of thing you'd tell a junior developer to avoid in code review: By tying one design decision (what access levels are possible) to another (code style), they effectively made it impossible to cleanly change the design around the former, because the latter won't admit any more values.
- andyfleming 9y agoThe language design choice to use capitalization instead of a public/private keywords is, in my opinion, a poor one. It seems like they've made choices to minimize keywords rather than be explicit and intuitive. I'm not saying that it can't be learned/taught. Also, IDEs like GoLand help, but at the end of the day the capitalization approach seems like an unnecessary annoyance
- tschellenbach 9y agoPython does something similar with the _hidden __morehidden syntax. Some people will like the syntax, others won't. It doesn't really change anything about what you can achieve with Go.
- pdpi 9y agoIt's awkward but can absolutely be learned and taught. What makes it really idiotic is that the spec literally ties visibility to a single, specific unicode character class. This has the hilarious effect that, for example, Latin, Greek, Cyrillic identifiers are allowed to be public, but Arabic, Korean (Hangul) or Thai are not!
- s17n 9y agoNope, the point is consistency in large organizations. In other languages, teams develop naming conventions like these. Having them in the language reduces the overhead of reading a new codebase.
- andyfleming 9y agoThere's a difference between consistent code style and forced language conventions. Also, I'm not sure you'll be able to convince me that reading "public" and "private" add meaningful cognitive load to reading code.
- s17n 9y agoRight, the difference is that the former isn’t real. When you have millions to billions of LoC developed by thousands to hundreds of thousands of developers anything not forced isn’t going to be consistent.
- andyfleming 9y agoYou can enforce code style through linting and CI. In some projects I've worked on, code doesn't get merged if it doesn't pass code style checks.
- s17n 9y agoThey could easily add more visibility levels (by using keywords like Java). They haven’t because it’s unnecessary and confusing.
- andyfleming 9y agoI wasn't necessarily advocating they add _additional_ visibility levels, but they already have at least 2. They are just implicit by capitalization as opposed to explicit with "public" and "private" keywords.
- zaphar 9y agoBoth are explicit. One uses a keyword the other uses capitalization. The compiler will still complain if you use a private method in either one. You can argue about whether one is more or less readable than the other but you can't say they aren't explicit.
- andyfleming 9y agoYeah, I guess you are technically correct as far as being explicit. Maybe intuitive is a better description. A newcomer could read public/private and quickly understand its meaning as opposed to capitalization being a learned convention.
- pdpi 9y agoLet’s say they add keywords. What happens then? How does that interact with the current rules, and with people’s ability to interpret code?