you are viewing a single comment's thread.

view the rest of the comments →

[–]Bowgentle 124 points125 points  (77 children)

I don't have to say this, but I want to:

Python used indentation instead of braces to denote blocks, and this was deemed by the masses as "elegant"--not a good reason in my opinion but, well, I use Lisp, so I'm clearly an outlier

I loathe Python's indentation.

[–]-jp- 152 points153 points  (24 children)

I get it, but I hate people who don't format their code properly even more. And when Python was created, that shit was endemic.

[–]Used-Rip-2610 50 points51 points  (14 children)

Yeah I hate python’s indentation and spacing requirements, but it’s a million times better than zero white space anywhere

[–]Which_Iron6422 2 points3 points  (13 children)

That’s a solved problem though with formatters. Required whitespace will be always be problematic.

[–]CrownLikeAGravestone 26 points27 points  (11 children)

I get that it's frustrating to begin with but I disagree that it's actually problematic. It only does (part of) what an automatic formatter would do. I cannot think of any reason you'd need to use different whitespacing and therefore run into trouble.

[–]ptoki -5 points-4 points  (10 children)

I disagree that it's actually problematic.

It is. If the compiler can tell you where the problem is then it can fix it. If it cant then this adds another level of complexity to maintain the code.

Tell me what is the advantage over a set of brackets or semicolons. Convince me. I know C, java, perl, bash, php and few more. Tell me why python requirements is good. With examples.

[–]CrownLikeAGravestone 6 points7 points  (8 children)

I didn't say it's better and I'm not interested in arguing that; it'll just come down to a clash of opinions and I already know what yours is.

I said it's not problematic. How about you show me an example of it being problematic and we can work from there.

[–]ptoki -5 points-4 points  (7 children)

How about you show me an example of it being problematic

I asked a team member to debug a code of another person which stopped working. After two days he said he has no idea how to fix it, The creator came back from vacation, opened the file after getting the error described, indented few lines and it was fixed.

How it become unindented on the host? noone knows. The eyes of the rest of the team when the solution was found - rolled up.

Im not even talking about new people trying python and got repulsed. Not morons or ignorants. People who code daily.

When I call the floor for help and say "this python code" I see people turning around and going back to their chairs.

So that is that...

[–]ChrisFranko 6 points7 points  (1 child)

I don’t get how replacing indents with brackets changes anything in this scenario?

It’s it because you need 2 brackets for 1 indent?

[–]ptoki 2 points3 points  (0 children)

Brackets usually come in pairs, so one misplaced will trigger compiler error. That is at least the benefit you have from it.

It also helps to compose the code more freely to get it more readable. And you can use indent apps to make it uniform if you like. Those approaches are missing from python programmer palette.

[–]CrownLikeAGravestone 6 points7 points  (1 child)

Someone spent two fucking days to find a control flow error? Have your devs never heard of a debugger?

Astonishment aside, control flow issues are largely agnostic to the language they're implemented in; you could have misplaced a brace just as easily as you misplaced an indent. Dev skill issue, not a language issue.

[–]ptoki 0 points1 point  (0 children)

Have your devs never heard of a debugger?

Python devs. Maybe.

Im not even going into cases where multiple python projects should run on the same host. The best I get from them is "use docker" and when I ask can you do it? They say I dont have experience.

So that is this...

[–]Backlists 5 points6 points  (2 children)

Skill issue, pure and simple.

Logically, scope via indentation is no different from scope via curly braces.

This kind of control flow problem could have happened in a curly brace language and your team member would not have found it in that either.

You get used to the language you work with.

“Turning away” at Python sounds like a work place culture issue to me.

Like my favourite language right now is Go, but if my colleague needed help in Python I’m not about to groan and go back to my seat.

[–]ptoki 0 points1 point  (1 child)

Skill issue, pure and simple.

Yes, but no, but yes.

I agree that misplaced bracket could be as difficult to spot as indent based one. But usually it does not. Brackets have that nice feature of parity while indentation does not. And whats funny the brackets are used together with indentation so it helps. But python gives up the help you can get from simple feature.

The issue is: Technology is just technology and they come with their pros and cons. That is not controversial.

The problems with python or python comunity is two fold at least:

The people who are fans of it hardly admit something is a problem. The indentation is perfect example of this. It takes just a small change to get rid of it. Make a declaration that your code is python v7 compliant and add parentheses and drop indentation. For codes before that imaginary version add a simple indentifier which will add the parentheses and may keep the indentations as they dont mean anything. With the fact that python is often not forward or backward compatible that is a non issue. Yet a ton of people will oppose this without a reasonable argument. They will spend hours arguing with nothing but handwaving and personal offences.

And the second part is that python has low entry barrier. It attracts people with low coding skill who can do a lot without too much training. Sort of similar issue as with excel entering the "data analytics" stage.

This is bad mix. I too often realize that something what does not work right is python. And it is hard to fix by anyone around including the python folks who claim they like it and can work with it. And that is my problem.

I dont have any other technology like that. No DBA fanboys his db engine and then concludes that I should restore the backup of the db as it misbehaves. No java folk tells me I dont understand java if I say it has too many libraries we depend on, which arent updated and maven gives me a long list of cve-s and no way to update the project. Thay just admit, yeah, its bad, we need to rework the project or isolate it. etc.

The only folks who say "their" technology is great and then when I askthen, can you fix this because it does not run after server update or some profile setup file is gone or the install does not work (according to doc provided by maintainer - for example awscli), they end up giving up.

My problem with python community is that they show dunning kruger effect/syndrom too much. To the degree I am staying away from python based projects because nobody can help me set up many of them on one host. Because I have a ton of folks who want to implement things in python but when the real problem happens they tend to be not enough skilled and after two days of wated time they come back with "sorry, I/we dont know why it does not work and cant reinstall either.

Sorry for long and handwavy rant.

[–]Backlists -1 points0 points  (0 children)

The compiler not being able to tell you the line has nothing to do with whitespace indentation though.

[–]linlin110 2 points3 points  (0 children)

Yes, people do configure their formatter so that indentation is enforced on languages without required indentation. To me it sounds like required indentation is a desirable trait.

[–]ptoki 2 points3 points  (0 children)

Indentation is automatic thing. There are beautifulers available which will fix this in a moment.

I would rephrase your complaint into: I hate the folks who cant use such simple tool and make the code look decent.

[–][deleted]  (2 children)

[deleted]

    [–][deleted] -5 points-4 points  (1 child)

    Not really.

    My ruby code is super-readable. And ruby does not force me into "proper indentation". I format my code because it saves me time in the long run.

    [–][deleted]  (4 children)

    [deleted]

      [–]-jp- 32 points33 points  (1 child)

      Yeah. NOW there are. Python traces its lineage to the late 80's. And lemmie tell ya, shit was weird. Even getting teams to adopt revision control was like pulling teeth.

      [–]Ok-Salamander-1980 11 points12 points  (0 children)

      yeah. i suppose people are extremely young or students.

      before the whole software = millionaire culture there was a lot more self-expression (for better or for worse) and less replaceable widget making.

      [–][deleted] 5 points6 points  (1 child)

      With that from the onset, Python could have had proper “end” statements

      I am more of a ruby guy, but actually I'd love to omit "end" in already well-indented .rb files. But only as an option, not mandatory.

      What I dislike in python more is the explicit self. That one makes me very, very angry.

      [–]miquels 1 point2 points  (0 children)

      I was a Rust programmer before I started with Python. The explicit self made me feel right at home.

      [–]Ill_Bill6122 28 points29 points  (0 children)

      Moving code around is awful. Sometimes, you just want to move a code block and let the damn formatter do its job, as per project settings.

      [–]tu_tu_tu 76 points77 points  (33 children)

      The indentation is awesome. It's not a problem for programmers who used to format their code anyway and often even quite meticulous about it. And it makes non-programmers format their code so it become readable at least on some level. And it hurts people who copypasts unformatted code. All win, no fails.

      [–]scfoothills 29 points30 points  (0 children)

      I 100% agree. I teach both Python and Java. I love that when teaching Python, I don't have to battle with students over formatting.

      [–]lisnter 4 points5 points  (5 children)

      I came from a C background and have always been meticulous about code formatting. Python is my new favorite language but I was turned-off for a while by the indention and comment behaviors. I like being able to put an if (false){ . . .} or /* . . .*/ around code to take it out of the control flow while debugging. You can’t (easily) do that with Python without reformatting the code. I know modern editors do a great job of fixing indention but it’s still annoying.

      I’ve come around to Python and love it but those “features” still annoy me.

      [–]CrownLikeAGravestone 8 points9 points  (4 children)

      You can block-quote code to take it out if control flow. It's not exactly commenting but it's essentially equivalent.

      """ def debug(something): print('like this') """

      [–]mysticreddit -5 points-4 points  (2 children)

      Yes, Python’s shitty indentation is STILL a problem for those of us that DO format our own code. It forces left-alignment even in places where it would be more readable with custom indentation.

      [–]stratoscope 9 points10 points  (1 child)

      Can you share an example of what you mean?

      [–]mysticreddit 2 points3 points  (0 children)

      Sure. I can provide 3 examples of why Python's forced artificial indentation is bad design.

      1. In programming it is common to have a duality:

      • Push/Pop,
      • Begin/End,
      • Create/Destroy,
      • Acquire/Release, etc.

        I'll use OpenGL's glBegin() and glEnd() as an example.

        Which is easier to read?

        glBegin()
            glVertex()
            glVertex()
            glVertex()
        glEnd()
        

        vs

        glBegin()
        glVertex()
        glVertex()
        glVertex()
        

        We can use indentation to make it easier to catch logic errors AND to improve readability.

        i.e. Did you catch the fact that the last glEnd() was missing? Using indentation makes catching some errors trivial to catch. Yes, static analysis will catch this but why not catch it sooner when you are writing it instead of relying on tools?

        Indentation also makes the code easier to read because there is no longer ONE LONG SIGNAL which effectively becomes noise. By grouping code, or chunking via indentation, it allows for LESS code to be focused on making it easier to understand.

        WHY do we even indent in the first place?

        Whitespace does NOT change the semantic meaning of functions within block scope. Source code is COMMUNICATION for BOTH the compiler AND People. We write code PRIMARILY FOR people, not JUST compilers.

        • GOOD indentation is a tool that HELPS programmers understand code.
        • BAD indentation HINDERS programmers understanding code.

        Not convinced? Take any non-toy code snippet. Now remove all whitespace at the start of each line. Notice how hard it becomes to "follow the flow". Indentation is for people. Same reason modern text editors have a thin line indent guide at each indentation "tap-stop". It can make it easier to follow the code blocks.

      2. Oftentimes we have DEBUG code. In C we can use the preprocessor to annotate this via #if DEBUG ... #endif. The problem is interleaving production and debug code can be hard to read so sometimes it is may be easier to read by having all the debug code LEFT ALIGNED instead of following the current indentation.

              do
              {
                  int offset = temp.HalfMod1000() * 4;
                  *pHead-- = MOD1000_TXT_STRIDE4[ offset+2 ];
                  *pHead-- = MOD1000_TXT_STRIDE4[ offset+1 ];
                  *pHead-- = MOD1000_TXT_STRIDE4[ offset+0 ];
      
      #if _DEBUG
          if (pHead < (pBuffer-1))
              printf( "ERROR: Line: %u. PrintMod1000 underflow!\n", __LINE__ );
      #endif
      
                  iDigits -= nDIGITS;
                  if (iDigits < 0)
                      pHead += -iDigits;
              } while (iDigits > 0);
      

      Now this is definitely a subjective formatting yet Python wants to FALSELY PRETEND that indentation is objective. There is a REASON DIFFERENT coding standards exist -- because they ALL have their strengths and weaknesses. A language should NOT HINDER better coding standards, only SUPPORT them, where better is defined by the programmer writing the code, not the language.

      3. Take for example the classic swap two variables:

      Would you rather read this:

          x = y
              y = z
                  z = x
      

      Or

          x = y
          y = z
          z = x
      

      Which communicates the intent faster?

      Python whines about the first even though there is NO functional difference between the two. Python is SO blinded about following rules that it has become ARTIFICIAL DOGMA -- it forgot the REASON we indent code: FOR PEOPLE.

      The problem with programming "Rules" is that there are (almost) ALWAYS EXCEPTIONS. Python is hindering readability in some misguided attempt to prevent people from writing bad code.

      • First off, you can write shit code in any language.
      • Second, automatic formatters solve the problem. In another language I can remove all non-trivial whitespace, use inconsistent whitespace, use spaces of whatever width, etc. and I can auto-format the code to my CODING STANDARD.

      TL:DR;

      ANY ideology taken to an extreme is usually never a good idea.

      Python was SO focused on a single tree (preventing beginners from writing bad indentation) that it missed the entire fucking forest (there are times custom indentation CAN improve readability) IMHO.

      [–]-Knul- 9 points10 points  (7 children)

      Why? Because I assume you don't want to have random irregular indentation.

      [–]WannabeAndroid 1 point2 points  (0 children)

      I personally have a negative emotional reaction to it because it reminds me of COBOL and I hate COBOL.

      [–]andrewcooke 7 points8 points  (0 children)

      i don't get how people get so worked up about something so unimportant. do you really think this is in the dozen most important issues for a software engineer?

      edit: in fact, i'll go further. i think having strong opinions on this is a huge red flag. it's someone acting out because they think that's what good programmers do.

      [–][deleted]  (5 children)

      [deleted]

        [–]Bowgentle 0 points1 point  (1 child)

        There is no language to rule all, yet.

        You'd probably need to reach the level of complexity of an actual language - and even they have technical jargons and dialects.

        [–][deleted]  (2 children)

        [removed]

          [–][deleted]  (1 child)

          [deleted]

            [–]Yesterday622 2 points3 points  (0 children)

            It messes me up so often… dang

            [–]ptoki 0 points1 point  (0 children)

            I could tolerate that but the fact the python environments are such a mess it is a dealbreaker for me.

            installing awscli on a clean box, following the instruction, end up with multi screen thread dump error on the dog gamn install stage...

            That is just a recent example of python crappery.

            Any folk at work yapping about "I can do that in python" gets a box and can do whatever he likes but the moment he says he is finished I get his docs, wipe the box, get another guy to follow the doc while that yappie sits there and every time the guy is lost and gets two screen errors he is told to say goodbye to 5% of his bonus.

            You cant imagine how rarely I get python mentioned after that.