Hacker News new | ask | show | jobs
by RcouF1uZ4gsC 1924 days ago
One of my knocks against it is using white space for scoping/blocks a la Python.

While it may be great for beginners or for short scripts, over time it becomes a real pain when refactoring. Editors mess up indentation all the time when copying and pasting. You only have to inadvertently make a statement either incorrectly part of, or not part of an if a few times, before you become leery of that choice.

3 comments

I've been coding for 14 years and I've never had a "whitespace" problem. This just seems like a nitpick from nitpickers.

Coded in C#, python, go, ruby, elixir, nim, rust, javascript, typescript. Not once felt this.

I run into this a lot with Python, where when I manually cut/paste some block, I have to go up and double check all the lines are in the right place, etc. because an autoformatter can't do it correctly and obviously like it can in C++, e.g.
Whitespace as syntax is a somewhat controversial choice. Others will talk about missing semi-colon bugs or other delimiter-not-matching-whitespace bugs. Their counter "You only have to mis-indent an if relative to semi-colons once to be leery of that choice."

Most of the time (more often than Python), you can use parentheses if you really want. Getting everyone else on your team to stick to that formatting convention..maybe not so easy because, well, not everyone shares your opinion/values. :-)

Personally, I'm skeptical of the "great for beginners" point. I've helped a few beginners in Python who had subtle, yet program-breaking bugs just because their return statement was indented to the wrong level. It would have been easier to just use a brace-delimited language and run the autoformatter to reveal any discrepancies.

(Or we could be using a lisp, but that's another problem :) )