2 ms·
I'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 g
by pohl 17y ago
I'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.
- nailer 17y agoSorry poor Tortoise, you're putting words into Achilles mouth. Fortunately, Python gives you: * A helmet. It won't parse unblocked code like any other language. I'm not sure why you think blocking a second time with brackets would improve things or avoid this risk. But hey, if you want to wear a second helmet, that's cool. May you encounter others like you. :^) * A mirror where things are as large as they appear (the blocking looks like it executes), unlike other languages where these can get out of sync and cause problems. If you enjoy this risk, that's awesome. High five. * A handy warning light should you accidentally stray too far to the wall (Python will telling you that your readability is broken at the same time it tells you your blocking is - and you only need one fix). If you'd prefer not to be told about this, two places to fix things, and enjoy receiving badly written code, that's your prerogative and who am I to say anything other than that it's not mine. Achilles: Nice bike and helmet. Tortoise: No! Achilles: Er, ok. Could you explain? Tortoise: I need to get a helmet! Achilles: You're already wearing one. Tortoise: But what if I fall? Achilles: You're wearing a helmet, which will protect you. Tortoise: But I need to get a helmet. Achilles: No you don't, you're wearing one. Oh and by the way, you need to be visible at night. The helmet's reflective, so you probably don't want to cover it with another ... Tortoise: You're not listening to me! Achilles: I am listening, but I'm also disagreeing. Are you listening to my disagreement?