10 ms·
> the lack of explicit start/end markers for code blocks is a very unfortunate choice. > It was a bold choice by Python, but in my experience it turned out to
by dxdm 6y ago
> the lack of explicit start/end markers for code blocks is a very unfortunate choice.
> It was a bold choice by Python, but in my experience it turned out to be a poor choice
Could you explain why? I've heavily used languages with explicit block delimiters as well as Python, in collaborative environments, and the significant whitespace in Python does not really cause me any trouble. There is some slight overhead of making sure of the indentation when copy-pasting, but a decent text editor will make fixing things simple.
As for the theoretical mixing of or trade-offs between tabs and spaces - that's just not a practical concern that exists in my experience.
Of course that's a matter of taste, but the whole thing just seems like a minor detail to me - especially when we have the option of code autoformatting now.
Am I missing something here that makes other people's experiences much worse?
- magicalhippo 6y agoJust to give a bit of context, I've been programming for almost 30 years, using many different languages. I've worked on many things, but of particular relevance I was part of a small team for several years which amongst other things had a 100kloc Python project that I did significant work on. I continue to use Python for all sorts of smaller projects, and for the most part enjoy it a lot. I've worked on large C++ code bases for years as well, and many of the usual suspects. To take the most subjective part first, for me, I just find implicit blocks much harder to parse than with explicit start/stop symbols/keywords. My eyes and brain just seem to have an easier time identifying the explicit blocks. It's like writing sentences without using a period to end them, but just three spaces say. Yes it's a bit more verbose, but I find it really helps readability for me. This of course might very well be the way my brain works, or the way my brain learned to work as a result of my first programming experiences, hence being subjective. A bit more objectively, in my experience it seems easier for myself and others to make mistakes at the end of implicit blocks, either having a line indented that shouldn't be or vice versa. It is my experience that with explicit blocks those faults tend to stick out like a sore thumb. I even have an add-on for my current IDE which, amongst other issues, complains loudly about that. If the language had had implicit blocks it couldn't really do that to the same degree. I also find explicit blocks is easier to use with tools, especially when diffing. When using a language with explicit blocks I can enable the ignore whitespace feature of the diff tool and if say an outer "if" was added, you get about two lines that changed. With implicit blocks all the lines of the block change, so you got to scan through them to make sure no "real" changes were made. I tended to spend a lot longer on non-trivial Python merges compared to say C++ due to this. I've also had the misfortune to have to edit Python code using only simple tools, without any Python-magic or similar. It's a royal pain if you have to copy/paste code around. But yeah, I accept it mostly boils down to preference. I mean clearly there are some more objective metrics, but how you weigh those will be subjective so, yeah...
- dxdm 6y agoThanks a lot for explaining your perspective. It's interesting to me, since all the things you mention are not part of my experience at all, despite working with Python a lot. Even diffing, as you said, is easy because of the "ignore whitespace" you mention. Anyway, it's good for me to get a reminder that I can't so easily generalize from myself. :)