5 ms·
Redundancy is an argument against braces, not in favor. I disagree. I know that the word "redundant" sometimes carries a negative connotation, but the truth i
by pohl 17y ago
Redundancy is an argument against braces, not in favor.
I disagree. I know that the word "redundant" sometimes carries a negative connotation, but the truth is that it is a mere property whose value depends upon the context and associated tradeoffs.
Spacecraft have redundant systems, but those systems are far from superfluous.
Human languages have built in redundancies. Generally they are there for ensuring communication still happens in a noisy environment.
My music CDs have redundancy in the encoding, and thankfully at that: after years of accumulating scratches I could still rip them without loss of quality. Redundancy was a positive here too.
Redundancy is a tradeoff, not an automatic downside.
- nailer 17y agoAgreed about context, but let's be clear: spacecraft and music CDs have redundancy to prevent loss. What loss are you preventing by requiring blocks be delimited twice? Have you considered that inconsistencies due to repetition are frequently themselves cites as a cause of data loss? Ever had code that looks good to you but doesn't parse because a machine is expecting an extra bracket?
- pohl 17y agoI'm no rocket scientist, but I'm pretty sure that not all redundancy in spacecraft is aimed at preventing data loss. If you look closer you'll see redundant gyros for attitude control, redundant sources of power (solar panels, fuel cells) and probably numerous redundancies in environmental subsystems on the ISS (air, water, waste), and even redundant explosive bolts for stage separation. I think jacquesm already mentioned the value of the redundancy above: you will never have a situation where a change in indentation leaves you with a runnable, but semantically-different program when you pasted code from a forum or from a machine with different tab settings. Note how the missing-bracket case in your last question is superior to this: a missing bracket offers fail-fast detection of the problem. If you indent a line wrong your program may still run, but differently: indent the last line of a block at the wrong level and it may happen after a loop rather than inside a loop. The indentation is for the person. The braces are for the compiler. I like this, personally. I understand how some may prefer the python way (it has a superficial elegance, after all). But I personally don't like the downsides that jacquesm mentioned.
- nailer 17y ago'you will never have a situation where a change in indentation leaves you with a runnable, but semantically-different program when you pasted code from a forum or from a machine with different tab settings.' In that situation, with any computer language, you'll have an unreadable program. In Python, you'll need to fix the readability before the program will execute - which is a win to me.
- pohl 17y agoI'll admit I don't know what magic the Python interpreter is capable of. I was imagining cases where an indentation change does not break readability: for foo in bar: foo.fizzle() baz.wibble() ...versus... for foo in bar: foo.fizzle() baz.wibble() ...how would it know that I wanted to wibble the baz every time I fizzle a foo, as opposed to wibbling the baz only after all foo have been fizzled?
- nailer 17y agoBecause you've told it to by making your data look correct. Python executes your data the same way you yourself parse it: by how it appears. Brace requiring languages execute your data using different rules than you use to parse it. Redundancy of logic is universally known to be a poor engineering practice.
- pohl 17y agoTortoise: I'd like a bicycle helmet, please. Achilles: Why do you want to wear a helmet? Tortoise: So that I won't hurt my head if I bump it. Achilles: You won't bump it. Tortoise: Suppose I do. Achilles: You won't bump your head. Tortoise: But suppose, hypothetically, that I fall off my bike and bump my head. What would protect it from injury? Achilles: Your head is not injured, because you didn't bump it. Tortoise: But that's the very basis of my hypothesis! Achilles: Yeah, I'm going to just ignore you said that, and tell you again that you won't bump your head. Tortoise: How do you know? Achilles: Because you made sure that it didn't come into contact with anything. Tortoise: Good night, dear Achilles. May you encounter others like you.