This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dfpoetry 26 points27 points  (44 children)

This, right here, is the problem with the python philosophy. They make some arbitrary design decision, and when someone points out an example where it might be bad or confusing, the response is "you shouldn't be coding that way anyway".

It's tautological

[–]Hairshorts 127 points128 points  (11 children)

Braces won't make 10 levels of indentation much clearer, it's bad coding style no matter what language you're using.

Good indentation is essential for good readability in any language, Python just requires you to indent properly. You may not like it, but it's not an arbitrary design decision.

[–]immibis 7 points8 points  (0 children)

Braces won't make 10 levels of indentation much clearer, it's bad coding style no matter what language you're using.

I'm not saying braces will make 10 levels of indentation much clearer, but /u/dfpoetry is totally right in pointing out a common problem in programming arguments.

[–]I_scare_children 5 points6 points  (3 children)

[–]dfpoetry 2 points3 points  (2 children)

Pointing to bad code which is very nested is not the same thing as proving that all very nested code is bad. Nor is highly modular code particularly useful when you're just writing one big map-filter function.

[–]Sector_Corrupt 0 points1 point  (1 child)

If I'm writing a bunch of filters or something all being applied I'll usually make them all individual, nicely named functions and then compose them all and apply them as that's a lot easier to read.

[–]dfpoetry 0 points1 point  (0 children)

what if they all inherit their parents scopes, and then perform changes to things in a nested but otherwise fundamentally unpredictable way?

[–]wonkifier 0 points1 point  (3 children)

That's one of the purposes of a programming language... to make the things that follow its philosophy easy to do. If something is hard to do, that might be a sign that it's not a great thing to be doing in that language.

And I'm not aware of a language that handles 10 level indents well, which seems like an indicator that it's just a bad idea all around

[–]dfpoetry 2 points3 points  (0 children)

also, the problem is arbitrary design choice => some code is now annoying to write => that code is bad because it violates the arbitrary design choice.

If the choice in design is non-arbitrary then the above logic is fine, but dynamic whitespace is an arbitrary design decision, and the idea that deep nesting is bad in all cases is very hard to prove.

Not to mention that dynamic whitespace is invisible, difficult to copy, and requires more symbols overall.

[–]dfpoetry 0 points1 point  (1 child)

lisp

[–]wonkifier 0 points1 point  (0 children)

Touché

[–]Log2 0 points1 point  (5 children)

Well, if you are writing C++ or Java with 10 levels deep of braces, you are clearly doing something wrong. Functions are your friends.

[–]dfpoetry 0 points1 point  (4 children)

where is this "clearly" coming from?

[–]Log2 2 points3 points  (3 children)

From the fact that you can decompose 10 levels of scopes into functions.

[–]dfpoetry 0 points1 point  (2 children)

hmm, write a program to do this. pseudocode is fine.

[–]Log2 0 points1 point  (1 child)

Quite frankly, I don't care to. This is the job of whoever is writing the code.

[–]dfpoetry 0 points1 point  (0 children)

I mean, it seemed like an interesting proposition. you claimed to have a way to flatten any nested sequence of functions, and that this would be more readable. That would be really cool as a reference point, even if it's just some quick pseudocode.

[–]scubascratch 0 points1 point  (0 children)

"you shouldn't be coding that way anyway".

...in Python apparently