HackerTrans
TopNewTrendsCommentsPastAskShowJobs

drahazar

no profile record

comments

drahazar
·ปีที่แล้ว·discuss
> I always assumed there was just something about the type of people who work in tech that they're weirdly more into climbing than average.

You were right the first time. Climbing is a largely constrained problem solving exercise with binary outcomes (you either did the route or didn't) and a built-in level-up style progression in the grading system. (Today I did my fist V2! etc...) You can do it entirely on your own, at your own time, in your own pace and it's not really possible to "lose" at climbing[1], you get unlimited attempts to try and figure it out. You can, for outdoor climbs, try the climb, fail, train for 6 months and retry the climb to succeed. In short it's almost designed to be addictive to coder types, but all that came before the indoor walls, not after.

Source: I climb obsessively. They got me good.

[1] - competition climbing aside, obviously
drahazar
·3 ปีที่แล้ว·discuss


  2.14 True/False Evaluations
  Use the “implicit” false if at all possible.

This one is my personal bug-bear. I find this:

  if not users:
     ...
significantly worse than:

  if users == []:
      ...
The second is totally explicit, reminds the reader that users is (expected to be) a list and makes it totally clear that we can only enter the conditional block if users is an empty list.

The first option:

a) obfuscates the type of users on first reading

b) evaluates to True if users is None (or LOADS of other things?!) which can lead to hard-to-find bugs.

Granted, type-checking can help here but purely from a readability perspective the second option seems way more friendly and for almost no downside. The same holds true for all of the "False-y" objects:

  if users == {}:
  if users == 0:
  if users is None:
  if users == ():
  if users is False:
Why is the implicit:

  if not users:
an improvement in any of these cases?

  If you need to distinguish False from None then chain the expressions, such as if not x and x is not None:.
!!!

Why not just:

  if x is False:

?