I'm asking this question NOT for comparison purposes or in order to decide which one the best. It's just curiosity.
I wonder is there any similarities between how apps build in React/Redux and Elm ? And if there any differences ?
By reading interview with Dan Abramov I know that Dan and Redux core team first created Redux and then discovered that Elm Architecture is very similar.
I wonder are similarities just end on how Redux designed or they go further ?
I know this kinda broad question, but in general I'd like to know how many common ideas between React/Redux and Elm. Are they same ideas and just implemented differently or they different in some important way?
Thank you for any explanation/clarification :)
I got an idea from the immutability site. It's huge. In pervious Web apps, for example Backbone and Vue, the Model part of an app is simulated with plain JavaScript apps wrapped inside a class. In Redux and in Elm, that's different since we don't embrace mutable states any more. And it changes the Model part a lot.
I'm on the Clojure side, in our words, values are not mutable, however references are mutable. For example, you got a variable for a apple called
a, it's two things. There's an apple and a variable calledathat is a reference to the apple. When you Joe holdsain his hand, it's merely a reference. As he changes the thing in his hand to a pear,abecomes a pear. An apple never changes into a pear, but the reference changed.Back to the Model, values in the model does not change themselves. With immutability, we have to create new values and mutate the reference. After the reference it changes, i.e. store is updated, we pass the store to the view to render it. In Clojure, reference is represented in an atom like
(atom a). In JavaScript, there's no clear concept like reference, it changes the variable directly. In Elm, it can be more complicated since languages like Elm abstracts mutable states with Monad and it's somehow beyond my knowledge. But the similarity is, you are prevented from mutating Model directly.And yes there's differences inherited from the languages, Elm, JavaScript are Clojure handles mutable states in different ways. JavaScript is simulating immutable data with mutable objects, it's never easy. I'm not able to explain the details, but you may have already felt that.