by bdg · 5y ago · 0 comments
There's this ritual you have to do when learning python: blindly accept status-quo design choices as "universally good" (but call it "pythonic"), and crap on other languages. Never admit python or the ecosystem has issues or shortcomings, and if another language has something better than yours (eg, Yarn, or Composer is way better than anything in Python (poetry is a good step but not a competitor)), or offer really good IoC tools: just double-down on the status-quo and say something like "looks over engineered, I see no reason why I would need that".
Pythonic is putting a decorator everywhere, coupling the system together into a ball of mud where you can't decouple it. Pythonic is having annoying mixed naming conventions. Why do I need methods to have underscores in 2021, but classes to use camel case? Why do my lines of code need to fit on a punched card invented decades before the language was invented? Why does the idiomatic "one true way" need to be what some other engineer thinks is "the one true" way?
Python is a fractal of closed-mindedness and single-use code. There's a reason it took a decade to get projects onto python 3, but PHP can swiftly move the entire ecosystem from v5 to v7 in a year. FastAPI is getting a lot of praise recently, but frameworks of this style are a dime-a-dozen in other languages and have been around for a decade.
Pythonic is a meaningless word that just gives firepower to the most confident-sounding engineer in a company to shoot down anyone who doesn't code like them. It's not an objective concept, it's innovation poison.
> Why do my lines of code need to fit on a punched card invented decades before the language was invented?
Keeping lines short helps keep information density high, allows you to fit more views of the code on screen without wrapping, and encourages use of intermediary variables to keep complexity per line low.
This isn't a Python issue. Any decent style guide will have a maximum line length.
> Python is a fractal of closed-mindedness
I don't know what you mean by a "fractal" of closed-mindedness, but you seem very certain of your opinions and not very open-minded.
My stint in python made me appreciate A line length more, but 80 got to be absurd.
My understanding is that 80 was originally chosen because that was the standard number of columns on a terminal. It has been continued to be used because it happens to be roughly just under half the width of a typical 16:9 or 16:10 monitor at normal font sizes, making it ideal for window snapping and side-by-side diffs.
I have to review code in other languages all the time which follow a style guide that defines a maximum line length of 120 or 160. It's a huge pain having to scroll left and right all the time. But I'm not about to replace my perfectly good 16:10 monitors with ultrawides.
> the standard number of columns on a terminal
are inherited from punched cards.
https://stackoverflow.com/a/4651037/257493
But in 2021 I can resize my TTY Emulator, we have better fonts, and screen proportions have changed.
A column length of 80 is in the ancestral DNA of computers because it was the number that packed nicely onto a sheet of paper. That paper was that size because it fit nicely into a paper portfolio and filing cabinet. The portfolio was that size because it was a reasonably big-enough sheet to adjust the paper cutter to.
80 has nothing to do with humans reading code. It's all post-hoc justifications and fairy tales. The whole thing is a 200 year old legacy system bug.
Personally I'm fine with either option, but I think lines much longer than 99 characters start to get pretty awkward. If you really do need longer lines than that occasionally you can mark an exception for whatever style checker you're using.
PHP did well with v5 to v7. It took more than a year but your point is well made.
The PHP v7 to v8 move is not as easy [1, 2, 3]. Not having Python 2 to 3 fresh in everyone's minds is one reason; not having failed PHP v6 is another. The breakages that led to the downfall of PHP6 made backwards compatibility a focus in PHP7.
Since PHP7 was released the contributors/voices who favour backwards compatibility have left or been drowned out. The emphasis on supporting legacy code has gone.
[1] https://stitcher.io/blog/new-in-php-8#breaking-changes
[2] https://24daysindecember.net/2020/12/21/a-perfect-storm/ (recommended reading)
[3] https://developer.yoast.com/blog/the-2020-wordpress-and-php-...
> I've very rarely encountered people being dogmatic about "pythonic" code,
Followed by...
> You've encountered one or two, and are extrapolating to an entire community about that.
I'll have to say my experience in "the community" has been far closer to his experiences than your equally small bubble.
These problems are applicable to all languages, not just Python.
Python can’t seem to decide whether it wants to be a production grade language or easy-for-beginners and keeps implementing pointless features (looking at you walrus operator and weird version or pattern matching) instead of fixing its actual problems like the tire-fire that is packaging and performance.
“But Python has never been about performance” someone will say, and that’s fine, but it’s increasingly becoming a language that isn’t any more ergonomic to use than its peers, with worse packaging and deployment, useful tools (type hunting) that the community seemingly refuses to adopt widespread and its slower on top of all that?
Why would you actually bother?
I have been burnt by this. As much as I like python's "expressiveness" so to speak, it is too slow for my needs; the ML community gravitated towards that because it is simple to implement and test large models because C++/C/Cuda are doing the lifting. However, in my flavour/field of ML, python is often the bottleneck because the sampling/simulations are glued with it and the need to sample 10s of millions of steps ends up with possibly billions of function calls in python.
In some contexts, that slight mismatch can escalate to become quite wide.
A deeper examination of Django would yield rich examples of this.
------------
The above is really a message for myself as an engineer who loves python and has an emotionally visceral distaste for PHP. I offer it to y'all in case you also find it useful insight.
I know this is not universal, but I've seen it online a lot, and lived it for far too long.
Know your needs and which language fits your needs.