4 ms·
Can anyone more knowledgeable on Elm comment on the "statelessness" as there still is a state. There isn't an explicit type alias for the state nor is there an
by kreetx 4y ago
Can anyone more knowledgeable on Elm comment on the "statelessness" as there still is a state. There isn't an explicit type alias for the state nor is there an explicit update though. Maybe "implicit state" would be a more fitting name here.
Also, given that they write about web technologies, then their static site returns a blank page when js is not enabled..
- KasMA1990 4y agoFor this post, stateful and stateless refers to how the component looks from the point of view of Elm. It's true that the DOM is very stateful, even when we're writing "stateless" Elm code though. But this is something one needs to know regardless of what kind of components we write.
- girishso 4y agoThere is state of course, but it is kept in the calling module not in the component itself. In other words, if component has a Model defined, it's a stateful component.
- cardanome 4y agoThe state is completely handled by the parent. So the component itself is indeed stateless. Basically, the message is: Avoid having components with local state, especially if it needs to be synchronized with the parent. Instead have one central place to handle state. Which is generally good advice and not really that Elm specific.
- hobofan 4y agoBeing restricted to only one central place means you have to wire everything to that central place. This usually results in writing manually mapping boilerplate between X different message types, which is one of the worst parts in every Elm(-inspired) project I've seen.
- KasMA1990 4y agoYeah, if you do mapping all over like that, it can get really bad. The solution, I feel, is to avoid the mapping by pushing more things closer to that central place (as outlined in the article). At least this works well for us when building a web client, but I can't speak to how easy it is if you're using that architecture for other purposes.
- tmountain 4y agoSome good answers already, but it's worth mentioning that "effects" are managed by Elm's external machinery (the Elm runtime) and delivered to your app via messages. There's a really well defined event loop and building apps is accomplished in a very boilerplate (read: consistent) manner. When an update occurs, your app responds to a given message which includes the current app state, and it returns a new state. That state is handed back to the runtime (possibly mutated), and whatever modifications you made will come back around in the next update. http://toreto.re/tea/ http://toreto.re/tea/
- zild3d 4y ago> Also, given that they write about web technologies, then their static site returns a blank page when js is not enabled.. Seems like a log management company that mostly writes about security and devops, not really a "web technology" site
- kreetx 4y agoRight, but the article itself is about how to do Elm better. Anyway, it probably isn't much of an issue to them, but, to hide the bottom popup Firefox's reader mode didn't work, so tried disabling js and discovered the issue. Gatsby does seem to have SSR though, so perhaps it's easily doable should they want to.
- jeofken 4y ago“State” means the current state of the program. What elms lacks is mutation of that state - you never change it, but only have a function taking the old state, and returning the new state. Thus every change is atomic, and you can record each change and in the debugger travel back and forth in time. Maybe calling immutable programming “stateless” is a misnomer, but “immutable state” would be better.