3 ms·
It's always seemed odd to me that a language with significant whitespace like Python became so popular, because human languages naturally have separators like s
by userbinator 6y ago
It's always seemed odd to me that a language with significant whitespace like Python became so popular, because human languages naturally have separators like semicolons and periods between sentences; otherwise, it all looks like one big run-on sentence. I admittedly work a lot in C and C-derived languages, and while reading I mostly disregard whitespace (as the compiler also does), so the latter is what code in other languages without statement separators/terminators looks like.
- ryan-duve 6y agoI see the point about dots, commas and colons being helpful. I just used them in the previous sentence for readability! On the other hand, I worked exclusively in C-like languages until about five years ago (I almost exclusively use Python now) and I made the opposite observation. In English articles, indented lists and paragraph breaks really pop, helping me understand the structure of what I'm reading at a first glance. When I realized Python's whitespace gives me the same thing, I find it hard to go back to curly braces defining blocks unless there's an additional convention of whitespace-indentation on top.
- qppo 6y agoMy pet theory is that a lack of non-whitespace separators heavily discourages clever one-liners or compact sequences of operations and forces the programmer to write more readable code.
- labawi 6y agoPython actually has ';', and I think you can write everything in one line if you really want to, e.g. in an inline script python3 -c 'import math; tau=math.pi*2; r=1; u=r*tau; s=r*r*tau/2; v=r*r*r*tau*2/3; print(u,s,v)'
- marvy 6y agoIn this simple script you can, but eventually you need an loop or something and you realize you're kind of stuck: before_loop; while something: step1; step2; after_loop; Note that after_loop is still inside the loop. Also you can't have multiple colons on the same line, so this doesn't work either: if test: do_this; else: do_that That gives a syntax error