January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 01/15/2013 05:00 AM, bearophile wrote:
> Chris:
>
>> or indentation (t)errors (Python)
>
> In practice Python usually decreases the number of indentation-related
> bugs,
Thats so funny I forgot to laugh.
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | On Tuesday, 15 January 2013 at 11:43:58 UTC, David wrote:
>
> Stereotypes of people who never actually used it, other than tried it
> and gave up because they didn't configure their editor correctly and
> blaming python for it. I bet my last indentation error was more than two
> years ago.
Not a stereotype, sorry to disappoint you, I have used Python quite a lot in my job (and still do). My point is, as soon as you have to use a specialized editor and configure the editor to format Python properly, there is something wrong, in my opinion. A language shouldn't depend on indentation. Indentation is just a means to an end (=readability) but not an end in itself. To make it part of the syntax is over the top, if not neurotic. Everyone in his or her right mind will use some kind of formatting anyway and avoid spaghetti code. No need to enforce it. It should be up to the programmer / team how to do this. But this is not a Python forum, and I am quite happy with the C-style D offers.
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to 1100110 | 1100110:
> Thats so funny I forgot to laugh.
One common indentation-related bug is caused by relying on the indentation to understand code, while the curly brace language compiler ignores what you were seeing and only sees the braces. I have seen many cases of delayed code understanding caused by that. Making the syntax more DRY (this means stating the logical indentation using only one communication channel) helps avoid those mistakes (and reduces the visual noise, further helping code readability).
Bye,
bearophile
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 15 January 2013 at 12:09:21 UTC, bearophile wrote:
> 1100110:
>
>> Thats so funny I forgot to laugh.
>
> One common indentation-related bug is caused by relying on the indentation to understand code, while the curly brace language compiler ignores what you were seeing and only sees the braces. I have seen many cases of delayed code understanding caused by that. Making the syntax more DRY (this means stating the logical indentation using only one communication channel) helps avoid those mistakes (and reduces the visual noise, further helping code readability).
>
> Bye,
> bearophile
That's not my experience. Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are and the fact that one missing white space (a typo after deleting a line) screws up the whole script is just annoying. The Python indentation terror is a peculiar personal preference enshrined in the language's syntax. It's simply not my style.
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | > That's not my experience. Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are and the fact that one missing white space (a typo after deleting a line) screws up the whole script is just annoying. The Python indentation terror is a peculiar personal preference enshrined in the language's syntax. It's simply not my style.
>
If you use notepad to write your Python Code yes. If you see yourself
too many indentation levels, that's a good indicator you're writing bad
code (bad is the wrong term, but can't think of the correct english word).
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | Am 15.01.2013 13:23, schrieb David:
>> That's not my experience. Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are and the fact that one missing white space (a typo after deleting a line) screws up the whole script is just annoying. The Python indentation terror is a peculiar personal preference enshrined in the language's syntax. It's simply not my style.
>>
>
> If you use notepad to write your Python Code yes. If you see yourself
> too many indentation levels, that's a good indicator you're writing bad
> code (bad is the wrong term, but can't think of the correct english word).
>
I think we are getting into a language flame, we should probably stop here. I love Pythons indentation because of various reasons, you don't like them.
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | Chris: > Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are If you use the standard 4 spaces indentations and you don't have ten indentation levels this problem is not common. Some persons also avoid your problem with an editor that shows thin vertical lines every 4 spaces (but only where the lines are actually reaching that length). > and the fact that one missing white space (a typo after deleting a line) screws up the whole script is just annoying. It's a small price to pay for increased code readability. And if I see one missing white space in D code, I fix it right now, so there is not a lot of difference. > The Python indentation terror is a peculiar personal preference enshrined in the language's syntax. It's simply not my style. Curiously the Python significant syntax was the motive for me to start using Python in the first place, years ago. I was looking right for that, being fed up of begin-end, curly braces, and those code reading mistakes I was talking about. Bye, bearophile |
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 15 January 2013 at 12:36:42 UTC, bearophile wrote:
> Chris:
>
>> Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are
>
> If you use the standard 4 spaces indentations and you don't have ten indentation levels this problem is not common. Some persons also avoid your problem with an editor that shows thin vertical lines every 4 spaces (but only where the lines are actually reaching that length).
>
>
>> and the fact that one missing white space (a typo after deleting a line) screws up the whole script is just annoying.
>
> It's a small price to pay for increased code readability. And if I see one missing white space in D code, I fix it right now, so there is not a lot of difference.
>
>
>> The Python indentation terror is a peculiar personal preference enshrined in the language's syntax. It's simply not my style.
>
> Curiously the Python significant syntax was the motive for me to start using Python in the first place, years ago. I was looking right for that, being fed up of begin-end, curly braces, and those code reading mistakes I was talking about.
>
> Bye,
> bearophile
Although Python gets bashed a lot due to this issue, it is not the only language doing that. Haskell, OCaml and F# have similar rules.
|
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 15 January 2013 at 12:36:42 UTC, bearophile wrote: > Chris: > >> Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are > > If you use the standard 4 spaces indentations and you don't have ten indentation levels this problem is not common. Some persons also avoid your problem with an editor that shows thin vertical lines every 4 spaces (but only where the lines are actually reaching that length). > > It happens very quickly if you have a class, a def, a nested for loop with one or two if statements class: def: for: if: You could call it "south west" code. > > Curiously the Python significant syntax was the motive for me to start using Python in the first place, years ago. I was looking right for that, being fed up of begin-end, curly braces, and those code reading mistakes I was talking about. > > Bye, > bearophile It's simply not my style. I don't believe indentation should be a rule. I clean up my code in my own way. |
January 15, 2013 Re: A look at the D programming language by Ferdynand Górski | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Tuesday, 15 January 2013 at 13:43:12 UTC, Chris wrote:
> On Tuesday, 15 January 2013 at 12:36:42 UTC, bearophile wrote:
>> Chris:
>>
>>> Nested for loops with if-statements can be hard on the eye in Python, because you have to go back an double check on which level you actually are
>>
>> If you use the standard 4 spaces indentations and you don't have ten indentation levels this problem is not common. Some persons also avoid your problem with an editor that shows thin vertical lines every 4 spaces (but only where the lines are actually reaching that length).
>>
>>
>
> It happens very quickly if you have a class, a def, a nested for loop with one or two if statements
>
> class:
> def:
> for:
> if:
>
> You could call it "south west" code.
>
>
>>
>> Curiously the Python significant syntax was the motive for me to start using Python in the first place, years ago. I was looking right for that, being fed up of begin-end, curly braces, and those code reading mistakes I was talking about.
>>
>> Bye,
>> bearophile
>
> It's simply not my style. I don't believe indentation should be a rule. I clean up my code in my own way.
I used to think like that a few decades ago.
Then I started working in multi-site projects with developers from all types of backgrounds, and understood the value of a consistent project code formatting.
--
Paulo
|
Copyright © 1999-2021 by the D Language Foundation