Benjamin Juang (ibneko) wrote,
Benjamin Juang
ibneko

  • Music:

Oh python...

Here's something about python that's a problem-

Since syntax / indenting indicates loops, there's irreversible loss of information. Take, for example:

marked = [0] * 1000000
value = 3
s = 2
while value < 1000000:
if marked[value] == 0:
s += value
i = value
while i < 1000000:
marked = 1
i += value
value += 2
print s

as someone posted as an answer to problem 10 of Project Euler. (Frankly, for that problem, I was lazy and just pulled a list of primes). But... without curly brackets used in other languages, the meaning of the code is completely lost.

Ruby, the other language I intend to pick up this break, looks like it's the same, but at least it uses "end"s, so I can quickly repair the syntax using regex. But python... :-\

Went searching on google for similar arguments: here's the best I've noted so far: http://www.parand.com/say/index.php/2006/12/11/on-python-ruby-and-whitespace/

In short, it boils down to:
Readability/uniform standards across the board (Python) ==VS.== No Data Loss with whitespace loss(Perl, C, Java)

Frankly, I would much rather sacrifice readability to losing data. Yes, there's ways to carefully post code online to ensure that your whitespaces don't get eaten by html/forum systems/databases, but that's more of a hassle*. And other languages could be written so it's readable too. Frankly, I rarely have an issue going back and re-reading my year-old perl code. And well-formatted code online is never difficult to read.

*and your easy options, such as PRE aren't always supported, so you'd have to manually go and do a s\ \&nbsp;\g replacement.
Tags: python
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments