Viewing a single comment thread. View all comments

dv_ t1_iy7n4qq wrote

It has been "the future" for decades now. In reality, aspects of functional programming have long since made their way into other, multiparadigmatic languages. I'm talking not only about primitives like map, reduce, fold etc. but also about isolating state, avoiding side effects, and making functions pure whenever possible. Functional languages enforce this, but you can do this in any language. Even C.

2

ToughAd4902 t1_iy9rten wrote

C does not support functions as first class citizens. You can do minimal amounts of things, like not writing mutable code, etc, but you can't do any form of true functional programming, as the language itself doesn't support it (though I guess you could write macros that unwrap everything, but that doesn't really count). The language itself has to have some support or it's just not possible

1

dv_ t1_iya5n0h wrote

You can do map, reduce etc. in C, albeit with a serious amount of macro trickery or function pointer usage. And yes, this does count. Is it practical? I doubt it. But it is possible.

1

ToughAd4902 t1_iyaa2lk wrote

my point that it didn't count is just that the macro will unwrap it to pure C, which doesn't have those constructs, so in terms of the language it doesn't actually support it, you're just adding a syntactic idea about it.

Though, to be fair, I guess that's all higher level languages do as well at the end of the day, so I guess my argument is kind of mute

1