3 ms·
Python can be easy to read, but it's filled with "gotcha's" and occasionally infuriating syntatic "sugar". Don't get me wrong -- I like the language and the eco
by azalemeth 5y ago
Python can be easy to read, but it's filled with "gotcha's" and occasionally infuriating syntatic "sugar". Don't get me wrong -- I like the language and the ecosystem is increasingly good -- but I find it plenty confusing enough at times. Perl's main footgun was "everything is a regex". Python's is "everything is an object". Of course, that it's main strength. A quick example:
$ python3
>>> dir(dir(dir))[(not False)*41].upper()
'INDEX'
>>> type(dir(dir(dir))[(not False)*41].upper())
<class 'str'>
- SAI_Peregrinus 5y agoYou can write hard-to-read code in any language. You can't write easy-to-read code in any language. Python tends to make easy-to-read code easier to write than Perl does.
- guenthert 5y ago> You can't write easy-to-read code in any language. I've seen (rarely) old shell scripts and even assembler made readable by copious use of comments. I think the claim should rather be that you can't write easy-to-read self-documenting code in all languages.
- t-3 5y agoThe issue is with data movement, in my opinion. Heavily pipelined command languages like shell and stack languages tend towards unreadable because they perform actions on arbitrary data with implicit transfers between functions, which can be confusing to the uninitiated, because you have to know every (not necessarily obvious) command and it's parameters beforehand.
- macksd 5y agoI agree that a lot of the implicit type conversions are problematic, but Python's handling of that is hardly as unintuitive as things like a lot of Perl syntax, or JavaScript typing, etc. If that's the kind of impractical example you have to come up with to showcase this problem, honestly I think that's still pretty good, and I'd still call the implicit type conversions an overall win for the use case being asked about. I think we could make better languages than Python that fix these issues. Like an implicit boolean -> int conversion does more harm than good, IMO (and it appears in your example). But I'm still not surprised that of the languages we have had when we have had them, that Python absolutely dominates this space.