2 ms·
The basic idea is that, keeping all other things constant, the code with the least surprises and paradigm shifts is the more maintainable one, because almost al
by cornholio 3y ago
The basic idea is that, keeping all other things constant, the code with the least surprises and paradigm shifts is the more maintainable one, because almost all code innovations have a learning curve that pays back the more you use the concept.
The maintainer is by definition on the losing end of that tradeoff, because they have to learn lots of things about your code and have limited opportunities to apply that learning. So poor code without surprises is much better than poor code that tries to take you outside of your comfort zone.
- Pannoniae 3y agoBut it also raises the average software quality by educating the maintainer. If all you do is write Python the same way your entire life, your code quality won't be that great. This is a fairly small sacrifice for a greater societal gain.
- c_crank 3y agoPython itself was designed with the intent of pressuring programmers to write Python in one specific way. The problems that crop up in large Python codebases are probably the result of using Python outside of its intended scope of scripting and toy programs.
- Pannoniae 3y agoYes. But people do use (or more like, misuse) Python for different things such as large systems. In cases like that, others still scream about "pythonicity" and "idiomaticness" just for the sake of language policing, even if those guidelines make zero sense. I had the misfortune of using Python for.... larger systems than it was intended for, and the code reviewer basically screamed at me for daring to use staticmethods instead of free-floating functions. Even though it was an internal implementation detail and it was exactly the point that the function itself shouldn't be discoverable if you import the file. But convention and being pythonic trumps everything... So yes, I think that people who criticise others for not writing "idiomatic" code just want to nitpick most of the time.