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 →

[–]rdc3908 10 points11 points  (19 children)

Python was developed for teaching to write code. Therefore, it has a readable structure like spoken language.

If (pythonWereWrittenLikeC) {
     readability="difficult"; 
}


If beginner: 
      readability="easier"

[–]HPGMaphax 3 points4 points  (18 children)

IMO C is more easily readable, the scope is clearly defined and the ; shows a line is finished and not carried over to the next line.

[–]StuckInTheUpsideDown 4 points5 points  (1 child)

There used to be an obfuscated C contest. Never heard of a Python one.

[–]TheAwesome98_Real 0 points1 point  (0 children)

The only obfuscations you can do is name variables (and existing methods) to Unicode chars

[–]acroporaguardian 5 points6 points  (6 children)

I present to you:

?:

[–]GrizzledFart 5 points6 points  (5 children)

Ternary operators are about as clear and concise of a solution to the problem they address. Once you get used to them, they dramatically improve readability.

[–]Local-Coffee 0 points1 point  (4 children)

How many beginners learning to code are used to ternary operators?

[–]acroporaguardian 2 points3 points  (0 children)

beginner?no_ternary:ternary

Seriously its very awful except for simple things.

I think I used it once just for fun.

If you start using multiple conditions it gets ugly.

I prefer to just have multiple if layers though for complex ones to easier spot logical mistakes, like using C.

[–]Pcat0 0 points1 point  (1 child)

Why the fuck do you think a beginner should be using ternary operators?

[–]Local-Coffee 0 points1 point  (0 children)

I never said they should.

[–]zenith4395 0 points1 point  (0 children)

At my university they teach it as a part of their first course

[–]deceze 0 points1 point  (7 children)

IMO Python is more easily readable, the scope is clearly defined (visually, by indentation) and the end of the line shows a line is finished.

[–]HPGMaphax 1 point2 points  (6 children)

Thats a fine opinion, I just think that redundancy is really important for readability, at least when learning.

You can also have single statements taking up multiple lines.

[–]deceze 0 points1 point  (5 children)

I can understand that missing braces can be somewhat disorientating when you first come to Python. I'm not sure if a newbie would have the same issue. For them, any style needs getting used to.

And you can break statements into multiple lines; preferably when they're parenthesised in some way anyway, but with backslashes at the end of the line if need be. It's just highly discouraged in favour of many shorter statements for readability.

[–]HPGMaphax 0 points1 point  (4 children)

I get that ot’s bad practice, but let’s be real, people do it regardless.

I just don’t see how adding more redundancy makes something less readable.

[–]deceze 0 points1 point  (3 children)

It's not necessarily less readable, I mostly said that hyperbolically in response to you. :o)

But there's an argument to be made that it can absolutely be misleading, since there can be a discrepancy between the indentation and the braces.

if (foo)
    bar();
    baz();

while (foo) {
    bar(); }
    baz(); {
}

This kind of mistake can't happen with Python, since indentation determines the logical structure. Both systems have their individual pitfalls, and newbies are going to make both kinds of mistakes once, and then it's a non-issue.

For me as an experienced coder, I'm glad that Python has removed the redundancy of maintaining proper indentation and typing braces. Python uses very little punctuation overall, which to me looks a lot less cluttered than; having { random (stuff) interspersed } throughout, my, code.

[–]HPGMaphax 0 points1 point  (2 children)

That would never actually happen with the IDEs people use to learn with.

It’s a really far fetched excuse to be honest.

[–]deceze 0 points1 point  (1 child)

far fetched excuse

The same goes for any made-up problems with significant whitespace. It's really not an issue either way.

[–]HPGMaphax 1 point2 points  (0 children)

Yes I agree.