5 ms·
I've always had the opinion that computers should serve the needs of humans, not the other way around. In languages where white space is insignificant, it is p
by dbcurtis 9y ago
I've always had the opinion that computers should serve the needs of humans, not the other way around.
In languages where white space is insignificant, it is pretty much universal that we use syntactic elements to communicate block structure to the compiler, and white space to communicate block structure to humans. Having two different ways of communicating block structure is: a) redundant and wasteful, and b) a source of bugs.
So, if you buy into the idea that having two different ways of communicating block structure is somewhere between an annoyance and a language design defect, and also buy into the idea that computers should serve the needs of humans, then it follows that the compiler should extract block structure from source the same way that humans do. That being: significant white space.
The {} languages seem very primitive to me any more.
- qquark 9y agoYou could argue, using the same logic, that when using {} languages, the computer can serve you by automatically doing the indentation anyway. This is the case in practice: I never have to worry about indenting my code in C, as support for that in most editors is great. {} languages have the advantage of allowing you an immediate restyling of the code when the original author (who can be of varying skill level) wrote something you don't like looking at, or when you want to change the style of your own code for various reasons. I find that Python-style blocks generally cause me more mild annoyances than {} blocks. A frequent thing that happens is copy-pasting/moving a line from some place to another with a different depth: In C, I paste and run my automatic indentation, while in python I have to specify manually by how much I want to indent my new code so that it can know within which block I want it. ... And it's not like you could do so automatically: if I want to paste something after the code of an "if ...:" block, the editor cannot know if I want it inside or outside the block. On a more abstract level, I personally prefer a language where the end of a block is explicitly specified by the presence of a visible character rather than by the absence of an (arguably) invisible one, and where the form of the code does not affect its function in any way... I'm not trying to argue that much against the python logic though, because the potential for disastrous style is indeed limited, it has its specific advantages, but I don't think delimiter-based languages can be qualified as more primitive just because of this.
- dbcurtis 9y agoI agree that modern tooling largely erases the tedium of getting indentation right. Whether C++ or Python, selecting a block and hitting either tab or shift-tab fixes indentation. (Which beats the heck out of re-indenting on punch cards, which I'm old enough to have used for CS homeworks...) And, yes, it is hard to argue that presence of {} makes a language objectively more primitive, which is why I used the word "feel"... the syntactic sugar necessary to keep the block structure straight just looks like noise to me any more. But as with many things, it comes down to personal preferences.
- newen 9y agoI find that the amount of bugs I tend to get when I copy-paste code far outweighs any potential aesthetic pleasure I get from seeing no begin-end block identifiers. Also, I don't want to let python have credit for not having those block identifiers because python has the colon begin identifier, which is completely redundant.