10 up and 4 down, posted by xat 644 days ago 9 comments
Discussing React vs. Vue on the internet ist mostly a waste of time. People tend to be biasd towards their favorite library, like it is some sort of religious cult or something. I'm not excluding myself from this.
Maybe we would get better results if both groups were only allowed to write about the negativ parts of their favorite library.
I just realized that you made this comment on a link *you* posted XD
The "cognitive load" for Vue templates is totally exaggerated: the syntax is very readable and easy to remember. Do you really think that v-if and v-else are harder to remember than all the inline JSX tricks using && || ?: operators ? In the end, people reinvent the wheel and create their own custom DSL in JSX with utility functions/components like this one: https://github.com/sospedra/mayre
Vue developers can use JSX since Vue 2.0 but most of us prefer using templates and single file components because they are clean, readable and easy to write. Also, JSX requires a transpilation step whereas it is optional for templates. It's hard to tell how JSX could be an improvement for us.
The only thing I'll say outside of that is with any DSL, there is a learning curve (big or small, still present) of something that will not translate when the inevitable porting to the new hotness comes around, since it is specific to the framework. Having performed several of those "rewire everything because the old frameworks property syntax does not align at all with the new", this greater degree of longevity is valuable to me.
Just because we don't like JSX does not make us "HTML oriented engineers", if such a job exists. This is something I often hear and it always sounds arrogant to me.
I find it very presumptuous to claim that JSX will survive the next trend in web dev. JSX came with React and already cause issues today when used with other trendy tools like TypeScript (hence TSX). It is also very close to standard-compliant alternatives such as hyperx using template strings. Considering that JSX is far from reaching consensus outside of React community, I doubt that this is a lasting solution.
JSX is popular in many frameworks actually, admittedly often frameworks inspired by React and has a pretty wide support. I've used templates and never liked them, I much prefer JSX and the && or ternary operator are just standard JS that anyone already knows. That's actually why I like it - very close to HTML, easy to fragment into multiple functions, everything inside curly braces is just standard JS. But I understand not everyone agrees just saying..
I did not claim that JSX would survive the next big thing (I've been doing this too long to think anything will last more than a few years), you took my point out of context. Rather, the idea is that neither thing will stand the test of time, so imho it is a little safer to go with the thing that sticks closer to the native language. But trust me, only a little safer, it's mainly a comfort level thing.
And the HTML orientation is less about JSX as it is about how you approach building interfaces. Template languages make the DOM the focus, supersetting the features there and making it the focal point for triggers, updates, etc. Thinking DOM-first in engineering style leans itself to this approach. JSX makes the data itself the focus, and the DOM is a pure reflection of the data. Thinking data-first leans itself to this approach. Again ... A comfort level thing, no right or wrong, because both methods solve the problems we face.
I think the only real gotcha that catches me frequently is "className"... The rest, not so much. Also starting to like JSS as well. It's just such a natural fit, even if it feels much more verbose.
JSX does feel much more like HTML + JS to me than any templating library ever has. From handlebars/mustache to angular, to vue, to whatever else. JSX is a realization I'd been hoping for since first working with E4X (which never gained adoption outside moz), it was just a nice way to work with things, and imho JSX is better still.
Vue supports jsx too, but heck, comparing the two feels a bit like apples and oranges to me (yes, they are both fruits); probably a react+mobx comparison would've made a bit more sense... but I do agree that templating in vue or angular is a danger zone :)