Would you rather be safe or free?in other words, my experience with coding stylesStory:I found myself being amazed and furious, seeing how strict code checking rules at Ecole 42 (School 21 now) were on my first day during the entrance intensive exam in Kazan. I had very little prior experience with python, writing bots and studying at Inha. Never before I had my way of writing code limited and inspected this way. I was doing all sorts of shady stuff and neither the prof at Inha nor his assistant bat an eye. But Ecole was complete opposite. First time moving out of town, It doubled the cultural shock.
Your function is more that 25 lines?
- Failed
You have too many variables or function params?
- Failed
Oh you don't have proper suffixes for your type, struct, function names.
- Eat dirt
Having "working code" was not enough, I hated it. To validate and get the XP for a given project, we had to pass about 3 peer reviews, linting checks and of course code must be tested and have no memory leaks. We were forced to fix the problems and deal with all the restrictions. Despite the restrictions, many peers made amazing stuff, games, shaders, 3D rendering engines, parsers, shells all written with little to no 3rd party libraries. The rules didn't limit creativity, they enabled collaboration.
Rules were unusual for me, but I got used to them in the next couple of weeks. Now I could read any peer's code and start understanding in little to no time. Because everyone, over a thousand students, followed the same set of rules. I could find code snippets of students from all over the world, be it Japan or America, and learn from them.
Real world:Not all codebases are the same, and, I had to get hit with reality check to appreciate the value of rules. And oh-boy was it unpleasing sometimes. Especially during internship, everyone had their own style, you'd open up their project and get lost. Not because they were a bad programmer, but because we didn't have a ruleset that everyone needs to comply with. I messed up so many projects myself because I didn't follow a proper style and was too lazy to write good code because I was the only one working on them. I regret it.
I concluded that code readability is local to the team and the project. There's no readable code, It's more about how much of a particular style one spent time reading and writing. Don't optimize the style for someone from outside to be able to read anytime, chances are, nobody ever will. Optimize for yourself and the team. And if anyone wants to read your code they'll learn that style if they are serious about it. And probably making the correct decision is to just use a community standard(ish) style. It doesn't have to be perfect, it needs to be
enforced and
consistent.
My answer:I will enable myself maintainable freedom through discipline. Real prison is spending your "freedom" to clean up your own mess.
What do you think?
@qishloqi_dev