3 ms·
People always talk about separation of HTML and JS is a separation of concerns, but it's really not in my experience. It's separation of technologies. The JS h
by daveidol 6y ago
People always talk about separation of HTML and JS is a separation of concerns, but it's really not in my experience. It's separation of technologies.
The JS has to grab DOM nodes by class or ID and is highly coupled to its structure anyway, so putting them together (as React does) seems far more logical in my opinion. Separating them into files and using string classes to look them up is far less easier to read and leads to runtime issues (since a typo isn't actually a code error but just silently doesn't work).
JSX is really not like PHP at all. PHP just writes out strings - JSX is all JavaScript objects. What you are describing is more akin to something like Handlebars or Angular templates. Plus, JSX is just sugar and is not required to use React if you prefer something like hyperscript (no compile step needed in that case).
- keyle 6y agoFair enough, my PHP in the browser line is a knee jerk comment which is extending its welcome. My point mostly was: separate view from logic. Intertwining them only makes maintainability and cognitive juggling worse.