3 ms·
While I agree, within the same context, I want to point out that right next to rasterization you have shaders, which are a poster child for functional programmi
by MaulingMonkey 10y ago
While I agree, within the same context, I want to point out that right next to rasterization you have shaders, which are a poster child for functional programming.
A vertex shader just transforms an input vertex (and some other inputs) into an output vertex, and a fragment shader just transforms an input fragment (and some other inputs) into an output fragment. This is done at a scale so massively parallel that we have dedicated hardware for it, because your CPU doesn't have enough parallelism.
Sure, HLSL and GLSL are locally procedural. The most recent fancy versions ofo them even allow for some shared state mutation within a thread wave, useful for certain niche uses. But in in their traditional contexts? I find even local mutation for most use cases to merely be a source of bugs and obfuscation via poor naming. And most of the built-in functions are pure.
- VladimirGolovin 10y ago> Sure, HLSL and GLSL are locally procedural. Just wanted to add that shaders lend themselves very well to the functional / dataflow paradigm. There are numerous visual node-based shader editing tools where you construct shaders from blocks, which essentially are pure functions.