logoalt Hacker News

systems10/11/20241 replyview on HN

the gleam tour is also very good https://tour.gleam.run/

very very good


Replies

xorvoid10/11/2024

From the tutorial:

// Division by zero is not an error

io.debug(3.14 /. 0.0)

It prints 0

Yuck. Division by zero is an unfortunate reality but basically nobody with mathematical background thinks that just defining x/0 = 0 is a good solution.

Often in numerical computing, getting an NaN or Inf is a blessing in that it’s a hint that your algorithm is numerically buggy, in the same way that a crash or a exception would indicate a program bug.

This approach is the numeric equivalent of a program continuing on after an undefined variable, just assuming it’s 0. That was tried by scripting languages in the 90s and these days most folks think it was a bad approach.

show 7 replies