Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a non-Go/Python user, those two snippets look practically identical to me, although I understand just enough to have written the same comments. Unfortunately, the comments don't tell me what I'd really like to know about the code if I ran across it when debugging:

* What are b, j, and k?

* What's so significant about even numbers - or is 2 a magic number that could just as easily have been 3?

* What can I assume about results? Can it be empty, null, 10 elements, 10 million elements?

With proper naming and a good, brief chunk-level comment, I could tell at a glance whether this chunk is likely to be hosting my bug or not. 5 lines vs. 8 lines don't play much into it.

Actually, this really isn't what I think of when I hear "boilerplate". I think of, for example, the adapter pattern, or having to build up a finicky set of states every time some common task is done.



The first python snippet was meant to be identical to the Go one and the Go one is the one from the article.

> With Python, you can write the exact same code that asks for the same mental gymnastics.

The second Python snippet would idiomatically be written on one line and that's what the article is railing against for unclear reasons.

The comments would not appear in source code, they're supposed to illustrate the thought process of the reader as they encounter the source code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: