>"If you're never allowed to use a text editor/IDE that highlights braces or the space between them ever again would you still prefer braces to indentation?"
Yes. (Though that's hardly the worst thing about Python.)
> having curly brackets everywhere makes everything harder for me to read.
What really kills me are nested parenthesis. I think I'm just deficient compared to most capable programmers in the ability to see how they pair up, especially in plain monochrome text.
In addition to indentation instead of curly braces, Python uses way less parens, for instance in if and for statements.
> As much as I like Python the scoping based on spaces messes me up far too frequently
Not so much for me, but I like the rejection because consistency is more important. If I have a language where braces is used exclusively in one part and not the rest, I feel that's a bad design approach. At least in the case of Python, braces is a humor joke.
> My problem with this is that you have to make sure every contributor has the same editor settings. You have to also configure every editor before you can use it to write code in such a language, which is sometimes impractical.
I'm not aware of ever having to do any of these things. I'm not even sure what you mean by "configure". Every editor I've installed has always done the right thing out of the box and every contributor who isn't completely incompetent has done the right thing naturally.
Compared to my experience in curly-brace languages where indentation holy wars about and it's actually painful to read code in with a brace style you're not used to - I have more respect for the wisdom embedded in Python and PEP8 daily.
That is true, but mixing spaces and tabs is a contrived example. Literally nobody actually does that.
Same for the point about formatting, I think. The average python dev probably spends about as much time reformatting pasted code as the average C dev spends typing braces.
I guess my point is just I think you subjectively dislike Python’s syntax (which is fine) but are trying to make objective justifications for that which seem really far fetched. Why not just say you don’t like it?
> Syntax: Yep. Spacing blows and you're always going to have stupid issues with it. I hate Python's spacing. Someone ought to create a custom interpreter that allows for using braces.
Nope, for reasons I've explained up thread. In the meantime I suggest this code:
> for a language proud of getting rid of parenthesis
Er… what?
Python doesn't have braces, it has plenty of parenthesis. In fact, Python 3 added more since it upgraded several keywords to functions (not just print but also exec, and some forms of re-raising)
Since most of my professional experience is with C like syntax languages, I don't get how the lack of braces is an advantages, quite the opposite in my limited experience with Python.
Braces define scope unequivocally, they are easy to visually parse and don't care whether you are using tabs or spaces or even if you, loud gasp, mix them. Furthermore, you can copy and paste, say for loop from a method to another method and it will work. In Python you might have to faff about with spaces (I'm sure there must be IDEs that solve this problem but it was no fun on vim or even notepad++)
> The mixing between parenthesis and braces and the lack of standard indentation makes some derivations really hard to read.
For sure, you're absolutely right. I'm just saying that doing that in Python would have exacerbated the problem, not made it better. (Imagine someone taking the full power of Python and unleashing it on the derivation writing process, yuck.)
PEP8 (http://www.python.org/dev/peps/pep-0008/#tabs-or-spaces): "Tabs or Spaces? ... Spaces are the preferred indentation method. ... Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively."
>It's not any harder to get used to than using whitespace for blocks in Python, or having to end every damn statement with a semicolon in the C inspired languages.
Strongly disagree.
I can move from C to Python without a second thought and rewrite code from one to the other without even thinking.
Having to rewrite an algorithm working on multidimensional arrays that was written with 0-based conventions to 1-based conventions and have the resulting code remain readable is a freaking headache.
>spaces vs. braces: I don't hate braces, but spaces makes it more readable
Really?? This is my least favorite thing about Python. D: It can't possibly be more readable when you're talking about large code blocks. It just happens that we're never supposed to be talking about large code blocks in Python. "If you want to write a lot of code, you use another language," they say -- probably one with braces, which syntax highlighters can match-highlight on. In Python, you just hope the indentation is far enough to make it obvious where something ends and another thing begins.
> My vote is to get rid of the curly braces. All of us have suffered from bugs and compiler complaints from deeply-nested blocks of code where we get mixed up about how many closing braces are needed, and where they should be placed.
I cannot remember the last time this happened to me.
> I’d prefer requiring matching begin and end blocks, with the end statement indicating which block is being closed.
So you can close an outer block before closing inner blocks? Or you can omit closing of a block altogether? Why - doesn't this create loads of nasty ambiguity?
> Sure, careful indentation tells us the same thing, but so much code today has been modified by so many people that the original engineer’s careful indenting often becomes hopelessly mangled.
"Often"? Just fix that problem if, indeed, it IS a problem.
> I often put an indication of which brace is closing which block in the comments.
As others have pointed out, if you need to do this, you have bigger problems.
I do actually like Python's approach, although I don't have enough experience with it to judge if it's a big improvement.
> It's super funny to see people defend curly based languages.
Well, that's because they're not really "strictly worse" in every way. I find curly braces helpful for readability and cursor navigation. The latter is only possible with Python by completely parsing the code. Also I don't like reading vertically dense code, so having (almost) empty lines inbetween is fine. All subjective of course, but that's the case for every aspect of language syntax.
> Using curlies but not indenting properly is almost always a sign of a bug
I don't think anyone criticising Python's syntax cares about the freedom to have inconsistent indentation, that's not the point.
> And Python has plenty of oddball syntax: significant whitespace
Yes. Especially this. The whitespace thing in and of itself has kept me from ever developing a fondness for Python. Clearly there are plenty of people who aren't bothered by it. De gustibus.
> The computer is really quite proficient at inferring block structure from indentation, and if you use a modern editor this structure is manipulated rather effortlessly.
Nonsense.
Try pasting a block of Python into Hacker News and you get something that starts off like this:
import os
import random
def do_something(x):
if x:
fd = os.open(x)
and only gets worse. A language with braces/semicolons has no such problem; it is easier to communicate with others, and the absolute value of being able to communicate with others when starting a new language is exceptional.
> I can't articulate specifically why but using typing in Python just feels like so much pain compared to other languages that have "opt-in" nominal typing syntax (PHP et al.).
YES!! Every time I try something other than Python that requires braces, I am like "WTF, why do I have to type this extra shit! Such an annoyance."
reply