4 ms·
Does functional programming eliminate glue code? Is the sidewinder motion of the Turing machine the font of quadratic coding jobs?
by ipnon 5y ago
Does functional programming eliminate glue code? Is the sidewinder motion of the Turing machine the font of quadratic coding jobs?
- dhosek 5y agoNope, The author's view of glue code is that most of it is to make the data output by function A a usable input for function B. This varies from the trivial (I'm moving an integer from A to B. Piece of cake as long as A & B both have the same sized integer with the same endianness and we've defined what to do if A is outputting a 64-bit value while B is inputting a 32-bit value and A sends something that doesn't fit in 32 bits) to the nightmarish (a large, poorly documented binary blob with inconsistent protocols) to lots of stuff in-between. Programming is easy. Data is hard.
- cratermoon 5y ago> as long as A & B both have the same sized integer with the same endianness and we've defined what to do if A is outputting a 64-bit value while B is inputting a 32-bit value and A sends something that doesn't fit in 32 bits Well put. I still remember the time I helped a junior colleague debug an error (in C) simply by suggesting he look at the size of the types he was computing. Lightbulbs went off.
- xedrac 5y agoIn Haskell, monads are all about composition of types. While the glue code doesn't go away, it stays neatly in the bind operator's definition for a given monad, which makes the rest of the code compose very easily. So no, it doesn't eliminate it, but I think it makes it a lot more manageable.
- cerved 5y agoNo but it tends to enforce patterns that makes it a lot more manageable.