Excerpt:
Typically, math library functions are written in a low-level language like C or raw assembler to maximize performance. But general purpose languages (like these) don’t help developers avoid semantic errors in mathematical code.
How many times has this happened to you: you’re writing some math computation, and you accidentally write a plus sign instead of a minus sign, or put in the wrong constant? Your programming language can’t catch these bugs for you because its types, like
float
anddouble
, don’t distinguish betweenx
and-x
or between different constants.But numerical code could really benefit from compiler assistance with precisely this task, especially since we expect the user to test out several different implementations of some mathematical expression and compare them for accuracy and performance. Numerical errors really throw a wrench in that process (through misleading performance or accuracy numbers) and MegaLibm therefore aims to prevent them.