ibneko: (Default)
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.
ibneko: (Default)
I'm going to pick up Python (for Highbrow) and Ruby (for Warbook).

For python, I'm starting out by doing Project Euler.net: http://projecteuler.net/

That means for the next few days, you guys may be getting random notes from me regarding the strange things I encounter in the world of snakes and jewels.

Starting out with Python:
• print automagically adds a newline. Why?
(Also, slicing is kinda cool. I like the string_variable[4:9] notation..)
• Using commas to concat multiple things that aren't strings results in extra spaces. :/ Ick. Can turn it into a string by using str, or using printf style printing with %s, followed by %. Oh, perl, how you have spoiled me.
• The forced syntax based off of indenting and lack of semi-colon line-endings still bothers me. Suspect I'll get over it eventually... hopefully.
• Where's my +=...?
• And... I can't do i++ or i--? EHHH??!?!?

[edit #...6ish]

Expand Cut Tags

No cut tags


ibneko: (Default)


RSS Atom

Most Popular Tags

Style Credit

Page generated Oct. 20th, 2017 02:10 pm
Powered by Dreamwidth Studios
November 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2016