3 ms·
I don’t consider myself an FP programmer but when I use modern C# for code that’s not terribly performance-critical, I use these FP concepts (purity, compositio
by Const-me 5y ago
I don’t consider myself an FP programmer but when I use modern C# for code that’s not terribly performance-critical, I use these FP concepts (purity, composition, currying, immutability, etc) when they’re a good choice. For suitable problems, FP can be awesome.
However, I often write performance-critical CPU-bound code, often impossible to do with FP. To write fast code for modern processors, programmers have to think about RAM layout and L1D cache misses. With these immutable data structures, FP code ain’t exceptionally fast because for optimal performance it’s essential to reuse the L1D-cached lines of virtual address space. Also, better to avoid any heap allocations on hot paths. Much easier to achieve these two things with imperative code, with their mutable variables, native stack and for loops.