Hacker News new | ask | show | jobs
by lsdafjklsd 3104 days ago
I really don't get the love around vue... I always read the glowing sentiment and go, "Ok, I'm missing something, let me go back to the vue.js docs and see what's good"

Things that are a deal breaker for me:

Template language... You can call it 'separation of concerns' all you want, but just let me generate templates using the language I already know, JSX is great

State management... I cut my teeth with Ember professionally for a few years, and really loved it up until I built a data intensive app. Having state spread across different controllers is great when you have many different routes and pages, but if one page turns in to a photoshop like app, controllers make a terrible state management tool. It doesn't seem overly complicated to me to use redux along with react-redux's connect function to connect regular functions returning JSX to your state object. Looking at Vue.js, it seems like I need to learn Ember-lite + Angular (custom directives).

3 comments

Are you sure you read the right docs?

> let me generate templates using the language I already know, JSX is great

https://vuejs.org/v2/guide/render-function.html#JSX

> controllers make a terrible state management tool.

I haven't used react-redux but vuex is essentially the same decoupling, and there's very little boilerplate. https://vuex.vuejs.org/en/intro.html

"Template language... You can call it 'separation of concerns' all you want, but just let me generate templates using the language I already know, JSX is great"

Not everyone knows JSX, so while that argument applies to you, it doesn't apply in general.

They mean javascript; jsx is a very small amount of new syntax and is embedded in normal javascript. Learning a completely separate template language with all of its own constructs for conditionals, iteration, etc. is significantly more work.
There’s not any more to learn vs html than jsx. It’s like 5 relevant constructs that all follow the same form, and the colon. Takes 20 minutes to have it down pat.

v-if is actually a big reason I prefer Vue. Ternary operators in JSX are pretty ugly. The other is that Vuex just feels so perfectly integrated. I've never felt Redux blends in particularly cleanly, though I certainly don't judge people that do prefer it.

Ternary operators in JSX are valid javascript expressions. As is anything that goes into {}

All of the following is neither Javascript nor HTML:

    v-for=”x in list”
    v-if=”conditional”
    v-on:click=“function”
    v-bind:key=“something.id”
etc. etc. etc.
I'm aware of that bit, I just think they're an ugly piece of control flow inside JSX, and they're also not a particularly versatile piece of control flow.

Especially for the else-if case - you end up with repetitive conditionals to replicate that.

If `do { }` syntax makes it into ES9, the whole ternary-operator-hate business will be a moot point
That's alright. I love and appreciate React too, I just prefer Vue now.
> and is embedded in normal javascript

Exactly! I don't know, but I've always found that disgusting. It turned me off React when I first saw it, and it still does.

Then people use it to defend react, and I'm just like 'Lolwut? Did we spend years learning that SOC is a good thing only to throw it out of the window?'

I'll be the first to admit that any Vue template quickly becomes soup as well, but at least it's only half of the soup.

Is it just younger developers that think React is the best thing since sliced bread?

JSX is a thin XML-like DSL on top of Javascript.[1] Unlike untyped strings with a custom parser of Vue, which require you to write something that’s neither HTML nor Javascript.

You can have as much separation of concern as you like with React.

[1] https://reactjs.org/docs/jsx-in-depth.html

JSX is also neither HTML nor JavaScript.
> JSX is a thin XML-like DSL on top of Javascript

^ this.

It directly translates to `React.createElement`. This is also why everything inside {} is pure Javascript including things like proper `this` etc.

I can’t stand Jsx personally. Vue files with the entire component defined in 1 place and writing HTML templates... preferred for me.