3 ms·
> One of the most confusing things I find with web development (which I'm mostly new to, coming from a backend background) is that everyone seems entirely happy
by unoti 9y ago
> One of the most confusing things I find with web development (which I'm mostly new to, coming from a backend background) is that everyone seems entirely happy with JS (or more accurately the DOM?) and CSS being giant mutable state buckets.
Actually, as you guessed, lots of people in the modern web community are unhappy with the mess of mutable state, and have done something about it! Redux [1] is all about using immutable state to tame the mess into a simple model involving application state expressed as an immutable object, the ui produces events, which get piped through a reducer, yielding a new state. If you skim over the "redux motivation" link below you'll see it talks all about the issues you're raising.
There are tons of variants of this theme, including NGRX which is the same concept applied to Angular 2. [2]
> CSS especially is a nightmare. It's near impossible in complex projects to work out if your change is going to change other things adversely...
I feel your pain, and have struggled with this endlessly in the past. However, this is a mostly a well-solved problem in modern environments. For example in Angular 2, the css is automatically scoped for you down to the component level in a sane way[3].
Try React with Redux, or Angular2 with NGRX and see if it solves the issues you're concerned with.
It's enough different options to make your head spin, I know. Just try out Angular 2 or Redux and see what you think.
[1] http://redux.js.org/docs/introduction/Motivation.html http://redux.js.org/docs/introduction/Motivation.html
[2] http://onehungrymind.com/build-better-angular-2-application-redux-ngrx/ http://onehungrymind.com/build-better-angular-2-application-...
[3] http://blog.ng-book.com/css-isolation-in-angular-2-components/ http://blog.ng-book.com/css-isolation-in-angular-2-component...