Iâve seen cases of C or C++ codes before, where the programmers add comments to the closing brackets or preprocessor end statements, e.g.
inline do_test()
{
#if (TEST == 1)
do_something
#endif //TEST == 1
}
More commonly, it is done for namespaces, where the brackets might span several dozens or hundred of lines of code. An example from nanoflann:
#ifndef NANOFLANN_HPP_
#define NANOFLANN_HPP_
namespace nanoflann {
// ... thousands of lines of code ...
} // namespace nanoflann
#endif /* NANOFLANN_HPP_ */
Judging by the following blog post, this also appears to be something people do in R to help identify pairs of brackets:
Auto-label closing parentheses in RStudio by Matt Dray
So the answer what is better is not clear cut. Personally, I like having the extra visual information on what construct ends. I donât think getting rid of two characters would impact my productivity in a language. I think I spend more time reading documentation, and thinking about how to code something. So calling this historical baggage seems exaggerated.
As @Beliavsky noted one should try to approach a language with an open mind, without his own bias baggage from previous languages. Of course the same holds in the other direction too.
Iâve found a paper related to this topic:
Chen, J. (2018). Linguistic Relativity and Programming Languages. arXiv preprint arXiv:1808.03916 . [1808.03916] Linguistic Relativity and Programming Languages
in which the author quotes a paragraph from Whorf:
[E]very person [âŚ] carries through life certain naĂŻve but deeply rooted ideas
about talking and its relation to thinking. Because of their firm connection with
speech habits that have become unconscious and automatic, these notions tend to be intolerant of opposition.
The authors continue:
Replace âtalkingâ with âwriting codeâ, and the analogy between speech and computer programs could hardly be plainer. An experienced programmer, practically by definition, internalizes the boilerplate and design patterns in code as âunconscious and automaticâ idioms to be regurgitated on demand (preferably with an editor or IDE that helps reinforce these idioms automatically). To the fluent Java programmer, wrapping everything in a class must be second nature, just as the R user is accustomed to seeing data in a data frame, or whitespace sensitivity to the Pythonista. Allowing for code as a generalization of speech, one could argue that Whorfâs observation predicted the very phenomenon of flame wars over programming language design!