News for hackers. Stuff that matters.
Re:An Honest Look at Urbit by creata on Monday October 04, 2021 @12:52AM (#28743227)
Okay, it's not insane, it just breaks from a convention followed by practically every programming language (and every logic / engineering / computing course) where integers can be interpreted as booleans. And that might be okay if there's a good reason, but the reasons given are pretty awful:

https://news.ycombinator.com/item?id=11852434

Re:An Honest Look at Urbit by nitrogen on Monday October 04, 2021 @02:47AM (#28743815)
Ruby is one popular example of a language with a truthy zero. This is to allow the use of truthiness to detect the presence of a value (as long as the value isn't false), even if the value is zero. Say I wanted to allow an environment variable to override a value in my code. I could do something like this:

    a = ENV['A']&.to_i || 1
and then run the program with A=0 to set a to 0.
Re:An Honest Look at Urbit by jstanley on Monday October 04, 2021 @03:12AM (#28743981)
Perl has this too. The string "0 but true" is truthy, but is 0 as a numeric value.

(Any string starting with 0 that doesn't evaluate to a different number also works - but "0 but true" is specifically exempt from causing warnings).

DBI uses "0E0" instead, which I guess more reliably evaluates to 0 outside Perl, and still doesn't cause warnings.

Re:An Honest Look at Urbit by int_19h on Monday October 04, 2021 @06:04AM (#28744914)
That approach is not unreasonable per se. But 1 being false is much harder to rationalize.