4 ms·
You're getting a bit bogged down in details, I meant it more as a general case. There are numerous cases where it is simply more efficient to be operating direc
by RyanZAG 13y ago
You're getting a bit bogged down in details, I meant it more as a general case. There are numerous cases where it is simply more efficient to be operating directly on data - the most used example I can think of are fragment and vertex shaders. It's irrelevant to the issue anyway though: simply having the ability to do something does not make it the best way to do something. You could code in a composable and immutable way using FORTRAN or COBOL if you tried hard enough.
The OP was asking for cases where you'd prefer to be using FP over the type of code he is used to. Manipulating blobs of sensor data are simply unlikely to be a productive use of FP - although it could certainly be done. However, calculating statistics from that data is going to be a place where FP would shine and would be a good choice for it.
Not everything is a nail simply because you can spend hours hitting it with enough transformations to make it look like one.
EDIT: Thinking about it, fragment and vertex shaders actually seem like a very good place to use FP.
- MichaelGG 13y agoEven when doing direct mutation of a byte array, FP can come in handy. The key part is being able to pass around and return functions. While I don't have experience "manipulating blobs of sensor data", most code can benefit from passing functions around and using closures. Even in otherwise imperative code, using folds and maps may make things clearer. Although, it might not be practical due to performance reasons.