2 ms·
This is great advice for many types of programs; for example, an application to be run in a web browser, or an interpreter. But there is a large class of progra
by leephillips 7y ago
This is great advice for many types of programs; for example, an application to be run in a web browser, or an interpreter. But there is a large class of programs for which “avoiding the assignment statement” does not apply. The author knows this, and mentions it in the “When you can't help it”
section:
“Sometimes, you just can't avoid the assignment statement or other side effects. Maybe you need so much efficiency that you have to mutate state to optimise your program”.
This class of programs includes all high performance numerical code. These programs compute by declaring large multidimensional arrays (usually distributed among multiple compute nodes), reading values from array elements, doing arithmetic on those values, and writing the results into array elements. These elements have fixed memory addresses, so the computation consists in changing the values stored in fixed memory locations. Efficiency comes from minimizing the movement of data and parallelizing as much as possible. It’s what Rich Hickey would call computing with places, not with values.