9

Redux is essentially functional programming, and it makes a lot of sense. As I move back to a non-javascript OOP language in a different project I would like to apply the same principles such as single state object, reducers which act on parts of that state, a business layer of semantic actions to modify the state.

My project is in C++ and I want to know if it makes sense to try and apply a functional, redux style approach to designing the application. Performance isn't super critical for this app, but maintainability is.

What difficulties would I face designing my app like this?


I should add that this is not a GUI app. And thinking about that more, maybe redux has reduced benefit in a non GUI application since there isn't some direct visual effect of the application state updating.

  • The guy who did the redux thing says he has an ES6 implementation, which is essentially Object-Oriented Javascript. – Robert Harvey Jun 9 '16 at 1:19
  • 1
    I looked into doing this in Java a while ago. You can make it work; Java 8 and C++11 are at least as "functional" as Javascript. But the static type system can make things kind of ugly. By no means restricted to GUIs, by the way; Redux's approach is extremely similar to how Clojure manages state under concurrency, which is not tied to GUIs at all. – Torisuda Jun 9 '16 at 1:22
5

Functional styles of programming tend to be somewhat reusable just about anywhere with the right mindset. The general idea of applying paradigms cross languages is what Steve McConnell refers to in Code Complete as "programming into a language". I mostly wanted to point out that the desire to apply lessons learned cross-language and cross-paradigm is truly the mark of someone who sees the language as an expression medium. It is amazing how many developers never reach this point.

As you point out, Redux's philosophy is targeted at UI development. It is hard to envision too many scenarios where the delta tracking of state is useful in non-UI environments. It really depends on your problem, though. If the approach makes the overall solution easier to understand and maintain, then it is probably a good one. The general approach that Redux takes feels a lot like the transaction journal in most RDBMSes, so it may well be true that the approach existed before JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.