3 ms·
... Start? C++ has been picking up functional programming paradigms pretty much since its standardization and the inclusion of the STL in that standard. C++'s e
by stormbrew 13y ago
... Start? C++ has been picking up functional programming paradigms pretty much since its standardization and the inclusion of the STL in that standard. C++'s evolution has been inexorably in this direction for a long long time.
- jerf 13y agoNot features, languages. We must be nearing the end of the game... C++ may be picking up whole countries soon.
- angersock 13y agoWon't do countries, because its Unicode support is garbage.
- bad_user 13y agoC++ has been an awful language for FP. First of all, you can't do FP without lambda expressions. It's just way too painful to do it without lambdas. Fortunately C++0x took care of that. Then C++ is a too low level language. Memory management is a bitch to deal with. FP is comfortable only in garbage collected languages, or otherwise you need a really, really well designed library and unfortunately STL ain't it, as STL has been plagued with memory leaks for years and still is. And many things in it are simply broken. For me the test for FP is pretty simple - a language is FP-capable if there exists for that language a comfortable and reliable library for persistent/immutable collections/data-structures. And this is in fact not enough, but rather the bare minimum. You simply can't talk about functional programming without immutable/persistent data-structures. Can such a library be designed for C++? It's much harder to do it than in say, a JVM language, or in Javascript, or in any garbage collected language, because of the memory management. Persistent data-structures rely on structural sharing for efficiency and in turn you rely on the garbage collector to take care of the junk when no longer needed. As an exercise, try to implement an immutable data-structure in C++, even a simple one like a linked-list and watch in horror the output of Valgrind as you're using it. I do think it's possible though, with a little care towards designing it. I think the TFA explains quite well the value of good design and even takes memory management into consideration. If more people actually do FP in C++, maybe one day we'll have an awesome standard and an awesome library that we could use for our FP needs. With that said, I really hope they won't leave std::future as is and I hope they do improve it. Adding a broken interface to the standard is not OK. If you can't design well an interface, then adding it to the standard does more harm then good. On the other hand the commute seems to be aware that std::future needs fixing, so that's good.
- stormbrew 13y agoTo be clear, I made no value judgement as to whether it was doing it well in that comment, only that it has been marching there for over a decade now.
- BartoszMilewski 13y agoFunny you should mention persistent data structures in C++. That's exactly what I've been working on. Here's my blog about leftist heaps translated from Okasaki directly to C++: http://bartoszmilewski.com/2014/01/21/functional-data-structures-in-c-leftist-heaps/ http://bartoszmilewski.com/2014/01/21/functional-data-struct... . It follows previous ones about lists and RB trees.