python vs d

Chris via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 30 01:52:47 PDT 2014


On Wednesday, 30 April 2014 at 06:12:24 UTC, Ola Fosheim Grøstad 
wrote:
> On Wednesday, 30 April 2014 at 01:46:21 UTC, Nick Sabalausky 
> wrote:
>> indentation rules. All it can do, and indeed all is *does* do, 
>> is blindly assume that the indentation as presented is correct 
>> and adheres to the universal style. If something is indented 
>> wrong, there is no enforcement, only bugs.
>
> Not blindly. Python will complain if the indentation does not 
> make sense. I very seldom run into indentation issues now, but 
> had some when I was new to Python. Just like C's syntax, it 
> takes some time getting used to.

Say you have a Python file with 500 lines of code. Try to copy 
and paste something with a different indentation from somewhere 
else into an if statement. You'll have to clean up before you can 
test the program. This kind of patronizing bullshit was invented 
for non-programmers who might make a mess of the code otherwise. 
Any programmer will structure and clean up the code once s/he's 
happy with it. Indentationists seem to assume that you cannot 
indent in C-style languages or if it is not prescribed, people 
will make a mess of it (which is patronizing fascist thinking).

In D you can do this:

if (mode == "TEST") {  // Second block added later
if (x == 1) {  // First block
  writeln("Hurray!");
}
}

In my opinion, this helps to test and bypass etc. things while 
debugging. Often I don't keep them, and if I do, I clean them up 
immediately as soon as I'm happy with it. In Python you have to 
clean up, even if it's just for 2 minutes of debugging / testing. 
Not to mention the nightmare of merging Python files with 
different indentation levels or styles (tab vs. space).





More information about the Digitalmars-d mailing list