As programming has become more popular, different coding styles have emerged, creating readability issues. Adopting a standard coding style can have a positive effect on maintenance, collaboration, and programming education, and can contribute to code comprehension in open source and educational settings.
Recent advances in IT technology have increased interest in the IT field, and many people want to learn how to program. Whether you buy a book and study on your own or spend a few months at a programming school, it’s now possible for anyone to create their own programs, even if they lack expertise. This is thanks to the development of various tools that make programming more accessible. For example, Google provides the Android Software Development Kit (SDK) for free to develop programs that run on the Android operating system. These tools provide convenience, making it easier for people with less technical knowledge to program.
However, the fact that anyone can program is not necessarily a good thing. The democratization of programming brings with it a number of problems, most notably the difficulty of reading program code written in different coding styles. Coding style is to coding what writing style is to writing. Writing is understandable as long as the grammar is correct, but writers use a style that suits the purpose of the writing to make it easier for the reader to understand. For example, in an academic paper, you want to be concise and clear rather than flowery, and in coding, even if the grammar is correct and the program works, the right coding style makes the code easier to read. On the other hand, if the coding style is not appropriate, the code will be difficult to understand.
As programs grow in size and are developed by multiple people working together, programmers need to consider readability so that others can easily read and understand their code. However, non-programmers with limited programming experience struggle to write readable code because they focus on creating programs that “somehow work,” and are not taught how to write “readable code.” Poorly readable code not only makes it difficult to collaborate, but can also cause problems when modifying the code in the future.
To solve this problem, we need to find a way to help beginners write readable code. I propose adopting a standard coding style to do this. By standard coding style, I mean a regulation that forces programmers to give up their individual styles and follow a set standard style. While most programming languages have no restrictions on coding style as long as you follow the grammar, standardizing coding style can help with code understanding and reduce readability issues.
Of course, the proposal to enact a standard coding style can be countered: everyone has their own preferred coding style, and a standard style can feel like an uncomfortable constraint to some programmers. It can be difficult and time-consuming to code to a prescribed style rather than your own. I’ve experienced these challenges myself. Last June, I worked as a grading assistant for the Korean Information Olympiad and wrote code to provide students with model answers. I tried to follow the style of last year’s model answers to make it easier for students to understand, but because I was following an unfamiliar style, a task that should have taken me an hour took me more than two hours.
While this standard coding style can make things less efficient, I believe it will have a positive effect in several ways.
First, in terms of long-term maintenance of the program, a standard coding style is efficient. Even after a program is released, companies continue to upgrade it by fixing bugs or adding additional features. Since programmers are often replaced during this process, it is necessary to have readable code so that new programmers can easily understand the existing code. Adopting a standard coding style reduces the need for programmers to think individually to improve readability, and a set style makes code easier to read.
In fact, some companies have even defined their own coding style for maintainability and require all programmers to follow it. When I toured Google Korea five years ago, Google emphasized that all programmers must follow the company’s coding style, while a friend of mine who works at a game company said that there is no set coding style.
Second, in the current trend of open source projects, a standard coding style would be a great help to programmers. Open source is code that is easily accessible to non-professional programmers as well as professional programmers, and it is publicly available so that various users can improve the program’s functionality and fix any inconveniences. Due to the nature of open source, code written in different styles can be mixed up, making it difficult to understand the code. I often utilize open source code for computer graphics, and I’ve experienced the difficulty of reading code due to the variety of coding styles. Having a standard coding style would have alleviated this frustration.
Third, in terms of programming education, a standardized coding style can also increase efficiency. It can also ease the burden on educators. Recalling my experience as an instructor at a programming school, I spent a lot of time reading students’ code and fixing problems. Students tend to write “code that works” rather than “code that looks good,” and hard-to-read code makes it harder to find bugs, which is time-consuming and stressful. If students wrote code according to a standard style, this difficulty would have been reduced. At Seoul National University’s Department of Computer Science, we have several courses that include readability assessments to encourage students to write readable code. As you can see, a standardized coding style would be beneficial for both educators and students.
For students, a standardized coding style can reduce confusion and increase motivation to learn. Every book or internet course on programming has a different style, and some may even teach the wrong style. As a trainee, it’s hard to tell which style is right and which is wrong, and you can end up a programmer who doesn’t write readable code. If we had a standard style, this wouldn’t happen.
So far, we’ve discussed the positive effects of a standard coding style, but we also need to consider the feasibility of standardization. On the flip side, the mathematical model of programming languages can make it difficult for computers to process coding styles in addition to grammar. There’s also the difficulty of converting all existing code written in different styles to a standard, and the debate over which style should be the standard.
While it’s hard to find positive answers to these feasibility questions, it’s becoming increasingly possible as research progresses. For example, Python is making an effort to regulate coding styles by adding a grammar condition called the indentation rule.
In summary, standardizing coding styles has many positive effects on maintainability, open source, and education. Computer science majors and non-majors, as well as those interested in programming, should strive to write readable code. This is difficult to do in the absence of a standard style, but for these reasons, I believe a standard coding style is essential.