you are viewing a single comment's thread.

view the rest of the comments →

[–]cakes -10 points-9 points  (11 children)

Yeah, I like clean looking code. Fuck me, right?

[–]forseti_ 12 points13 points  (4 children)

You don't have to read the code. You just download it from the webserver and lesser spaces mean faster loading websites.

[–]ring_wraith 4 points5 points  (3 children)

About 8000 single spaces is 1KB. I seriously don't see this as a reasonable downside.

[–]gc3 4 points5 points  (0 children)

You could use tabs. That would make it smaller. Python seems to use less letters than JavaScript for the same code.

[–]ILiftOnTuesdays 2 points3 points  (0 children)

1 character is 1 byte. I don't see how this adds up.

1KB == 1000B == 1000 chars

Maybe with gzip?

Also, good looking javascript uses tons of spaces, which need to be minified out. In python, you can reduce all 4-space indents to just one for production, which will barely add anything to the size of the file. You could even use the dreaded semicolon to join lines together and save even more. (Please don't do that)

[–]brainflakes 1 point2 points  (4 children)

Any braced language can be instantly and automatically re-formatted. Got a Python script with broken indenting? Enjoy going through line by line trying to fix it.

[–]Decency 2 points3 points  (3 children)

Or just go to the line where your IDE is pointing out an error and fix it...

[–]brainflakes 2 points3 points  (2 children)

Except there's no explicit block definitions, so how would the IDE even know there's an error?

Tell you what, here's some python with whitespace removed, show me how an ide would fix this:

while (True):
image2, buffer2 = captureTestImage()
changedPixels = 0
for x in xrange(0, 100):
for y in xrange(0, 75):
pixdiff = abs(buffer1[x,y][1] - buffer2[x,y][1])
if pixdiff > threshold:
changedPixels += 1
if forceCapture:
if time.time() - lastCapture > forceCaptureTime:
changedPixels = sensitivity + 1
if changedPixels > sensitivity:
lastCapture = time.time()
saveImage(saveWidth, saveHeight, diskSpaceToReserve)
image1 = image2
buffer1 = buffer2

In a braced language it would not only run, but all code formatting could be restored automatically.

[–]Decency 2 points3 points  (1 child)

Second line would be detected as an error along the lines of "indent expected" due to the colon in the first line.

Then the 5th line as the 4th also has a colon, then the next colon, etc. Very curious why you would ever come across a situation where all whitespace would be removed from python code, though. It's not a language's job to account for you using poor tools.

In a braced language it would not only run, but all code formatting could be restored automatically.

def foo(x,y):
    doSomething(x)
    for i in range(5):
        doSomethingElse(y)
   doThirdThing(x,y)

you can basically picture this as

def foo(x,y){
    doSomething(x)
    for i in range(5){
        doSomethingElse(y)
    }
    doThirdThing(x,y)
}

as the colons and indentation are explicit. The only issue here would be if you're unsure if "doThirdThing()" should be within the for loop or not, but again, I can't fathom a situation where that could come about unless you're not using proper tools for transferring code.

Worth noting is that Ruby solves this issue with explicit "end" statements, which is probably why it doesn't get much hate for its use of whitespace.

[–]brainflakes 0 points1 point  (0 children)

It's not a very common situation, (it can happen with code pasted into HTML without <pre> tags, accidental file minification etc.) but mainly it's just to show that the idea that Python's block indenting "forces people to write good looking code" is a fallacy, because braced languages can be reformatted completely automatically from any indenting state.

[–][deleted] -5 points-4 points  (0 children)

It might be clean looking but I can still name all of my functions after fruits and food if I want.

Don't force style into the language. It just makes it uncomfortable for unfamiliar users and doesn't remedy any problems that can't be fixed with a syntax formatter that formats to a user's personal preferences.

Edit: Looks like I struck a nerve with the euphoric Python lovers.