I will never understand the whitespace complaint. Any code you read in python will follow standardized indenting, by necessity. Why on earth is that a problem?
Yeah, I also don't get that. My Python code even has the same indentation as my Java code in university had. I just don't have to spell out the ; and the {}. But in the beginning it was really tough, especially because my eyes were trained to structuring code by {}. I think it's mostly a question about if you want to put in the effort to retrain your instincts or not.
I prefer having to add the {}'s and ;'s, even if the spacing is the same, because they provide a clear and definite bound on scoping, which (unfortunately) often gets messed up in Python.
Yeah that's pretty much what I also experienced. You won't get into that trouble that often, though, after you have trained yourself to the Python look. There are some quite tough problems where I really need to think if I put a line into an if block or not, but that the kind of trouble you have for logical reasons not because of having {} or not. I work full time on a Python project and I can't remember a single instance where I "misclicked" a line into or out of a block.
Personally I don't care, although copy-pasting Python can be annoying. If your biggest concern with any general-purpose programming language is its syntax, you have probably not put enough thought into semantics issues - the ones that persist no matter how familiar the syntax becomes.
Anyway, Walter Bright, designer of D language, wrote an article on language design [1] touching on the issue:
> Yes, the grammar should be redundant. You've all heard people say that statement terminating ; are not necessary because the compiler can figure it out. That's true — but such non-redundancy makes for incomprehensible error messages. Consider a syntax with no redundancy: Any random sequence of characters would then be a valid program. No error messages are even possible. A good syntax needs redundancy in order to diagnose errors and give good error messages.
I thought that was interesting. It is a pretty much undebatable argument against taking terseness too far.
On the other hand, I have never had a problem with Python's error messages.
The 'ideal' language, in my eyes, would allow terse representation of _algorithms_, not of the language syntax. This often means that you need several different ways to do the same kind of thing in different contexts.
"The syntax is terse" doesn't help if the libraries aren't. We want libraries and common concepts to be terse. That's why I feel that any language designed without heavy consideration for how it's standard libraries are to be used is a regressive exercise. Write your libraries how you want them to be used, then figure out the syntax from that.
Easy: because there are people who mistake being used to something for it being good. Also because people know too few different styles of syntaxes and are not required to learn more of them (let's do everything in X! from microcontrollers to OSes!), which makes them inflexible.
Syntax matters, but not in the way most people think it does. Syntax should be judged based on how well it supports semantics of a given language and not based on how "pretty" it is. EDIT: I should probably add that Python syntax matches its semantics and intended usage rather well; for an example of a conflict between syntax and semantics look at JavaScript.
> Python syntax helps the semantics pretty well I think.
Yes, I think so too.
> Why do you need braces
You don't. You need some kind of delimiters and newline+indent works just as well as any other kind of delimiter, like braces, parens, begin+end and so on and on.
- Cutting and pasting code may change its functionality. Especially from a non-source medium like web pages.
- I find myself fighting my editor's indentation a lot more as a result. Hitting return at the start of a line in the middle of an existing chunk of code indents to the previous line's indentation not the current line's indentation.
- It's asymmetrical: code drifts off to the right as you go down. Together with the editor issue I've taken to inserting a single '#' at points of down-indentation to mark this.
Your first complaint can be easily solved with a good text editor. I use sublime and it will handle whitespace differences when pasting. I haven't had any trouble pulling from webpages.
Secondly, it isn't any harder to indent after hitting return than to add a Bracket. Same number of keystrokes and again, a decent editor can fix this problem too.
Lastly, this is just a personal preference. Clojure code also drifts right, but its just a matter of training your brain to interpret it.
How can it handle whitespace differences when pasting correctly?
I have a conditional block. I want to paste some code at the end of it. Do I want to paste it inside the condition, so indented the same as the preceding line - or outside the condition,so indented one level less than the preceding line?
With a brace delimited language, if I put the cursor inside or outside the brace and paste, an editor has enough information to correctly indent it. With whitespace delimiting, the editor doesn't have enough information.