News for hackers. Stuff that matters.
Re:How we do Vue: one year later (2017) by keyle on Monday March 18, 2019 @06:38PM (#19426074)
I write Vue every day, in a large application. Only small bits use VueX.

Of all the frameworks I've used, it's brilliant because it hardly takes any thinking away from the business logic, so I'm not bogged down, it stays OUT of my way, and it's rock solid.

I HIGHLY recommend it, and this is from someone doing web since 1997.

Re:How we do Vue: one year later (2017) by ergothus on Monday March 18, 2019 @09:12PM (#19427157)
I'm too inexperienced to have a definitive opinion, but I'm not nearly so positive and wanted to toss out a contrasting opinion to the current comments.

After a few years of using React and some past experience with various other templating/view systems (webdev of one sort or another since '99) I started picking up a little Vue. So far it's been easy enough, but it is highly confusing compared to most other systems I know.

The syntax is like JS handled through custom HTML attributes. In one place a string is a string, in another it's a reference to a component property. If I want to iterate over a list, I spit out the `<ul>` and then an `<li>` that has special attributes that says to repeat it N times, filling in these different bound values. Compare that to, say, React, where my code is code, and my HTML looks like HTML (but is actually code) and the relationships become more clear, less magic. If I want to loop over an array and output some <li> tags....that is exactly what I do.

Vue reminds me of JSP...that's not a point in it's favor in my book.

Now - I've only been using it for a week, and there is so much more to learn. But in terms of first impressions, Vue has not impressed me...and I actually expected to be impressed.

Re:How we do Vue: one year later (2017) by BigJono on Tuesday March 19, 2019 @12:20AM (#19428056)
I've been using it for 6 months now, and I still can't wait to go back to React, for the exact same reason you mentioned. I'm 'fluent' in Vue now, and it hasn't grown on me in the slightest.
Re:How we do Vue: one year later (2017) by philliphaydon on Monday March 18, 2019 @09:24PM (#19427225)
I have the opposite feeling to you. The template feels like HTML to me and the syntax is clear and concise. React for me gets confusing with it all muddled together. But each to their own.
Re:How we do Vue: one year later (2017) by dmitriid on Tuesday March 19, 2019 @02:45AM (#19428612)
Compared to React (and React’s JSX) Vue’s syntax is orders of magnitude more complex and is very inconsistent: https://news.ycombinator.com/item?id=19199423
Re:How we do Vue: one year later (2017) by konart on Tuesday March 19, 2019 @06:49AM (#19429650)
I feel that this baybe the case when you know js very well and it's just easier for you to write 'custom-js' that will be transpiled to regular one.

I'm working on backend most of the time and relatively recently I needed to do switch to frontend part of our service. For me Vue seems much easier and less confusing. You just have your plain html template and a few 'hooks' to make it work with your js script.

>magnitude more complex and is very inconsistent:

Just as the other guy said - it is very intuitive. You don't even have to learn much of js to make it work perfectly.

Re:How we do Vue: one year later (2017) by eeeeeeeeeeeee on Tuesday March 19, 2019 @12:15PM (#19432231)
I think this is accurate. My background is also in the backend realm and so I'm not a frontend person and my Javascript knowledge is marginal. I recently had to take on a more frontend project and I went with Nuxt/Vue over React.

That being said, I do share some of the other comments about how it can be confusing with bound elements and iterating over objects, or areas you aren't allowed to use string concatenation. A lot of this magic happens behind the scenes so it's a bit of trial and error, and feels foreign if you're used to being able to do those sorts of things in the past.

I also think that React (with JSX) is a bit more "out in the open" about how things work and what is expected, without reading tons of documentation, and less under-the-hood magic. So it's easier to get up to speed, and your JS knowledge will improve over time (especially if you already know other languages).

Re:How we do Vue: one year later (2017) by dmitriid on Tuesday March 19, 2019 @08:15AM (#19430065)
Thank you! That is the best explanation I’ve seen on how people may perceive Vue vs React vs other frameworks. Never thought of it this way.
Re:How we do Vue: one year later (2017) by mmcnl on Tuesday March 19, 2019 @05:18PM (#19436016)
That's a very strong statement. To me the templating part of Vue is the least of my problems. While in theory you could make it sound complex by listing an exhaustive list of custom attributes, in reality this is almost never a problem. I have 2+ years experience in Vue, and I've never had any issues with the templating. Problems that are orders of magnitude more complex than templating are problems related to component lifecycles, functional composition, higher-order components, application architecture, server-side rendering + hydration, etc. None of this is solved by using JSX or some other templating language and these kind of problems exist regardless choosing Vue/React.

I feel like these kind of arguments are usually made by people who don't have any extensive experience using Vue, because in practice, it's not really a problem. Sure, you may not like it and prefer JSX (I understand all the pros and cons, all very valid), but that's a whole different statement than saying "Vue's syntax is orders of magnitude more complex and very inconsistent". That's just plain wrong.

Re:How we do Vue: one year later (2017) by dmitriid on Wednesday March 20, 2019 @11:19AM (#19443043)
> a whole different statement than saying "Vue's syntax is orders of magnitude more complex and very inconsistent". That's just plain wrong.

There is an easy test to see if my statement was true or false:

    <tag attr="x">
where "attr" is a Vue attribute. What is x and what can x be? An expression? A string? A function reference? An object? How will it be processed and presented in the end? As a string? As a function call?

At any given point in time the value in an attribute is entirely dependent on context (which particular Vue attribute it's in) and on a very arbitrarily defined rules for those attributes. For example, v-on accepts three absolutely different and incompatible things:

   v-on:click="x + 1" 
       A Javascript expression
   
   v-on:click="function_ref" 
       A function reference bound to JS-code

   v-on:click="function_call(param1, param2)" 
       Looks like a function call but isn't. It's a way to
       declare a function ref that will be called with bound params
And that's just one of the tags! I'm not even touching on the JS side of things where magic is abound (see comments at the end here: https://news.ycombinator.com/item?id=17471199)

Compare to React's JSX:

    <tag attr="x"> // x is a string
    <tag attr={{ x }}> // x is a valid Javascript expression
These are the same and they are consistent for every single attribute. The only limitations come from the meaning and the usage of the attributes themselves.

    <tag onClick={{ function_ref }}>
    <tag onClick={{ () => regular_JS_arrow_function() }}>
       onClick expects a function reference because that's
       what it will eventually call
And the rest around JSX? Plain old Javascript. Where this:

    {
      data: function () {
        return {
          open: false
        }
      }
    }
doesn't magically turn into this in a completely different part of the object:

    {
      methods: {
        toggle: function () {
            this.open = !this.open
        }
    }
Re:How we do Vue: one year later (2017) by bpicolo on Tuesday March 19, 2019 @09:07AM (#19430381)
You can use JSX in Vue if you so choose (https://vuejs.org/v2/guide/render-function.html). I personally prefer the templates, and I enjoy the usage of HTML attributes for loops / conditionals, but the option is there, and there's no one correct answer here that everybody can agree on (which is fine).
Re:How we do Vue: one year later (2017) by ergothus on Wednesday March 20, 2019 @02:41PM (#19445399)
I doubt we'll agree, but something as simple as: make an unordered list of hrefs with a url (based on name) and the name. Also, have a class on the currently selected <li> (currently selected meaning some variable matches the item name in the list) ends up with several special attributes, and a scope question (will a bound class see the iteration variable?) - all of which is not a question in something like React because there's not special scope being created, the same rules I'm used to always apply.

Different strokes for different folks, but I was quite surprised at my experience. Everyone keeps using the word "intuitive", and anything that I have to learn all these rules and special cases for is the opposite.

Re:How we do Vue: one year later (2017) by javitury on Tuesday March 19, 2019 @03:56AM (#19428891)
One thing I love about Vue is flexibility.

If you want to use pure javascript, you can create the render function directly and forget about templates. Most of vuetify components are pure javascript.

Also vue has support for JSX if you prefer that.

Re:How we do Vue: one year later (2017) by have_faith on Tuesday March 19, 2019 @06:06AM (#19429464)
This is the same for React. Not sure about Angular it's been a while since I've used it.
Re:How we do Vue: one year later (2017) by viraptor on Tuesday March 19, 2019 @02:29AM (#19428549)
> In one place a string is a string, in another it's a reference to a component property.

It's not wrong, but this way it sounds way more scary than:

"Properties which start with "v-" are treated specially by Vue and don't end up in the rendered output."

Re:How we do Vue: one year later (2017) by dmitriid on Tuesday March 19, 2019 @02:44AM (#19428607)
It doesn’t sound scary. It sounds correct and on the point.

Vue’s v-* attributes are a stringy mess [1], and it doesn’t really matter that they don’t end up in the output.

[1] https://news.ycombinator.com/item?id=19199423

Re:How we do Vue: one year later (2017) by odorousrex on Monday March 18, 2019 @06:53PM (#19426170)
>I HIGHLY recommend it, and this is from someone doing web since 1997.

I started in 97 as well, and cannot recommend Vue enough. I've done React, Angular 1 & 2, and I keep coming back to Vue.

I always feel like with React/Angular I'm conforming to work how they want me to work. (Esp. Angular - React is more forgiving). Whereas Vue is just a complement to the way I already work. I can use as much or as little of it as I wish.

A hearty endorsement indeed.

Re:How we do Vue: one year later (2017) by tashoecraft on Monday March 18, 2019 @08:30PM (#19426863)
So for personal projects or for small apps I think that’s great. But when I think about projects that need to live on well after I’m around, then they shouldn’t work the way I work, they should be in standard way that anyone can come into and know what’s going on. That jumping applications between teams feels simple.

This is why I like angular quite a bit, it’s not whatever the dev decided to do. It doesn’t include a whole bunch of small libraries of questionable support.

Re:How we do Vue: one year later (2017) by mygo on Monday March 18, 2019 @11:52PM (#19427946)
I think you might be reading into what the poster wrote the wrong way. the implications of a framework being able to be used the way the poster descibes is that it closely follows existing standards and best practices. So as opposed to forcing you to do things entirely differently, it helps you work the way you might already work. Quite different from an anything goes wild wild west. And as with any language or framework, whether or not it's hard to debug is up to the developer.
Re:How we do Vue: one year later (2017) by wwweston on Monday March 18, 2019 @08:47PM (#19426989)
It's been a few years since I checked in with Angular because the projects I worked on were distinctively unpleasant, so what I'm about to say may not be current. But at the time, the wide variation in project structure (and available opinionated approaches) and libraries/tooling of questionable support were definitely part of the problem (though certainly not the full extent).
Re:How we do Vue: one year later (2017) by tashoecraft on Monday March 18, 2019 @09:09PM (#19427137)
Yeah, if it’s been a few years things are pretty different. The RC era was a little rough, but things are pretty standardized now. I wouldn’t say go start building with it unless it fits your use cases, but certainly don’t stay away from it if you come across it.
Re:How we do Vue: one year later (2017) by kangoo1707 on Monday March 18, 2019 @10:52PM (#19427670)
I think OP does not mean that Vue is unstructured / non-disciplined. Vue does have a rigid structure and standard though, but it's pleasantly designed and doesn't get in your way. Maintenance has been a breeze for me.
Re:How we do Vue: one year later (2017) by koboll on Monday March 18, 2019 @07:38PM (#19426482)
Vue's templating engine, honestly, seems somewhat poorly thought-out.

The usual <div :something='stuff + "here"'/> way of writing it errs on the side of HTML over JS, using quote marks awkwardly to enclose a statement rather than JSX's more sensible curly brackets. It makes it harder to visually parse, and it's sometimes annoying to not be able to use one type of quote marks unescaped within the statement.

Overall, this is one of many ways in which Vue (like Angular) seems like HTML with functionality tacked on, as opposed to React, which is closer to idiomatic JS. I've used both extensively and I don't think I can recommend Vue over React anymore -- unless you're, say, prototyping and looking to build an app entirely on the client, with no build step, where Vue really shines. Or unless you're doing something HTML-centric, like converting a static site.

Re:How we do Vue: one year later (2017) by jimmy1 on Monday March 18, 2019 @07:55PM (#19426595)
I have to agree with this. Ultimately whether or not you like Vue or React better boils down to if you agree with the semantics of the web, and including them in your app building process (i.e you like html, and css, and just want to "pepper" in some logic and interactivity with JavaScript), or if you would rather just embrace JavaScript whole-heartedly.

Vue relies too much on overloading the string type for my taste (fundamentally, all JS libs do this to some extent). Too much magic happens with these string-based v-bindings.

Irrespective of that, these days I am hard pressed to not use typed JS in some form or fashion anyways.

Re:How we do Vue: one year later (2017) by dpisk on Monday March 18, 2019 @09:17PM (#19427184)
As far as component libraries that start from HTML, I think Marko has the best syntax. Attributes are always parsed as JS expressions, for example. There's still some quirks, but overall it's pretty nice. https://markojs.com/docs/syntax/

There are some benefits from just embracing JavaScript though, especially, as you mention, integration with things like TypeScript.

Re:How we do Vue: one year later (2017) by pbowyer on Tuesday March 19, 2019 @03:32AM (#19428797)
That attribute syntax is awesome! I've found VueJS's handling of attributes to be somewhat confusing, sometimes getting a different type passed through than I was expecting. Marko takes the approach that would least confuse.
Re:How we do Vue: one year later (2017) by enraged_camel on Monday March 18, 2019 @08:52PM (#19427020)
>>Irrespective of that, these days I am hard pressed to not use typed JS in some form or fashion anyways.

What do you mean by "anyways"? I use TypeScript with Vue and it's great.

Re:How we do Vue: one year later (2017) by jimmy1 on Monday March 18, 2019 @09:08PM (#19427124)
Despite whatever framework I use, I believe adding types improves it and reduces bugs, Vue included. (These days I'm favoring ReasonML and that skews me to React, but I believe Vue.js is also available on Bucklescript)
Re:How we do Vue: one year later (2017) by Rapzid on Monday March 18, 2019 @10:46PM (#19427640)
I could see it being great if everyone on the project were writing class components and using JSX. String templates and extended objects?

Mutiny.

Re:How we do Vue: one year later (2017) by Rapzid on Monday March 18, 2019 @10:41PM (#19427628)
My least favorite part of Vue. Proper intelisense/checking for the templates never materialized either. A start-and-stop effort or two languishing in the Github issues..

I have a feeling after Vue 3 hits and in a couple years JSX will be the defacto way to work with Vue.

Re:How we do Vue: one year later (2017) by petepete on Tuesday March 19, 2019 @03:23AM (#19428765)
Putting three bits of code/markup written in different languages in the same file was always a bad idea.
Re:How we do Vue: one year later (2017) by wishinghand on Tuesday March 19, 2019 @02:15AM (#19428492)
Non string values in props and attributes is basically my only complaint about Vue, but saying that it's HTML with functionality tacked on is so completely uninformed. It's got all of the functionality of React, and can do cool stuff with slots (both scoped and unscoped), renderless and/or functional components.

The "I wouldn't use Vue except for a small project" meme really needs to die too. Vue's build process is mature, has server-side rendering, and is used by some of the biggest companies in the world. If it's good enough for them at scale, it's good enough for the rest of us.

Re:How we do Vue: one year later (2017) by airstrike on Monday March 18, 2019 @10:32PM (#19427580)
> rather than JSX's more sensible curly brackets

I'm still waiting for the 2019 equivalent of http://haml.info/

Re:How we do Vue: one year later (2017) by hombre_fatal on Tuesday March 19, 2019 @01:48AM (#19428399)
I think Pug is the closest thing to Haml with traction: https://pugjs.org/language/conditionals.html

Here's a Pug -> JSX transformation: https://github.com/pugjs/babel-plugin-transform-react-pug

Detouring from the most popular path tends to come at the price of tooling idiosyncrasies that are rarely worth it, but it seems to at least work with eslint-react and has syntax highlighting in some editors.

Re:How we do Vue: one year later (2017) by airstrike on Tuesday March 19, 2019 @10:49AM (#19431284)
Love it! Thanks for sharing
Re:How we do Vue: one year later (2017) by mateuszf on Tuesday March 19, 2019 @04:25AM (#19429000)
How about Hiccup?

Some examples here: https://reagent-project.github.io/

It's not haml, but I'd argue it's awesome.

Re:How we do Vue: one year later (2017) by airstrike on Tuesday March 19, 2019 @12:37PM (#19432478)
Thanks. Seems nifty but ClojureScript is a bit too foreign for me
Re:How we do Vue: one year later (2017) by Can_Not on Monday March 18, 2019 @10:47PM (#19427649)
> using quote marks awkwardly to enclose a statement rather than JSX's more sensible curly brackets

Sounds like you should be making more use of computed properties and component methods.

Re:How we do Vue: one year later (2017) by yughurt on Tuesday March 19, 2019 @12:58AM (#19428186)
Use JSX in your Vue. It's supported just fine.
Re:How we do Vue: one year later (2017) by furicane on Tuesday March 19, 2019 @09:09AM (#19430395)
Basically, what irks you is that Vue separates presentation (visual) from the logic via <template> and <script>, reusing components via HTML elements is poorly thought out and binding values to attributes is bad because hey, you can actually use JS to compute the value.

Naturally, even though you can disregard the templating and resort to idiomatic JS, like one in React, you managed to develop an opinion after not using the features you like.

This just makes no sense honestly. I'm all for people having opinion to the point where you can blatantly say "I hate Vue because I like React more", there's literally no need for justification.

But spewing nonsense just to justify your preference is just bad. Are you a junior dev by any chance?

I've used both extensively and I can recommend Vue over React because React is a pile of mental manure. I never understood React hype, but then again - IT is a fashion business, and when "leaders" invent crap - flies tend to follow.

Re:How we do Vue: one year later (2017) by yura on Monday March 18, 2019 @07:54PM (#19426577)
>Of all the frameworks I've used, it's brilliant because it hardly takes any thinking away from the business logic, so I'm not bogged down, it stays OUT of my way, and it's rock solid.

That's exactly what it's like. Working with Vue doesn't even feel like you're using a JavaScript framework. You just write your HTML, your CSS, your scripts/data and you're done. Vue is brilliant.

Re:How we do Vue: one year later (2017) by kinow on Monday March 18, 2019 @07:43PM (#19426513)
I worked more with backend (Java, Python, PHP), but in my current project we needed a good UI, and decided to use Vue. No regrets. Using it almost everyday. I knew Backbone and a bit of Angular, but after using Vue, its cli, i18n, vuex, and also vue mastery, I'm not looking at any other tool for now.

The community around it is also extremely helpful.

Re:How we do Vue: one year later (2017) by kbody on Monday March 18, 2019 @06:54PM (#19426177)
Have you tried React in a similar setting? Personally I couldn't bear it and it's massive adoption on frontend pushed me away from following that route much. Vue on the other hand certainly looks more "logical" to my eyes.
Re:How we do Vue: one year later (2017) by keyle on Monday March 18, 2019 @08:01PM (#19426644)
Yes I've used React. React was ok, but I had to think React and work the React way. With Vue, I work my way with minimal conformance.
Re:How we do Vue: one year later (2017) by koboll on Tuesday March 19, 2019 @12:54AM (#19428163)
Weird, I came away with just the opposite impression. Vue forces you to organize everything in a certain way: data goes in data, computed properties go in computed, methods in method... it all felt very Rails to me.

React sort of used to have this problem, too, when you had to rely on classes for state, but the hooks era is a breath of fresh air. Everything is just a function. It feels freeing.

Re:How we do Vue: one year later (2017) by Semaphor on Tuesday March 19, 2019 @02:07AM (#19428464)
With Typescript classes that becomes better imo. Data are instance variables, computed properties are getters (and setters) and methods are instance methods.
Re:How we do Vue: one year later (2017) by gumcreme on Tuesday March 19, 2019 @04:53AM (#19429127)
To be honest, your post is like this submission. It's not helping people who want to decide. You just say Vue is great but people would like to understand why or why it might be better than React. This submission is also not helpful because it's from 2017 and I wonder why it is heavily upvoted and not a newer post. Things changed in two years and again, readers would like to understand how Vue compares against React but in 2019.
Re:How we do Vue: one year later (2017) by codegeek on Monday March 18, 2019 @06:57PM (#19426205)
Curious how do you deal with state management in large application if you are only using small bits of vuex. I am writing this vue application where one component has become so huge that I would like to break it into smaller components but then passing data around in props is a nightmare. So I then need to look into something like vuex. So how do you get away from that in a large app ?
Re:How we do Vue: one year later (2017) by Townley on Monday March 18, 2019 @07:02PM (#19426239)
It depends a lot on what you're hoping to do. There's a happy medium for a large app between "every component manages their own state/props and those of their children" and "every component is a stateless vessel for VueX data".

I think if you're at the point where "passing data around in props is a nightmare" that's the pain point that VueX is meant to resolve, and it should feed into the solution. But following the principle of "components should manage their state without VueX if it's easy/convenient for them to do so" is a good way to avoid the global state becoming too unwieldy.

Re:How we do Vue: one year later (2017) by keyle on Monday March 18, 2019 @08:00PM (#19426635)
That's a problem you'll have with any of those frameworks. Personally I have endpoints that ask for the data at a component level and if they're small, they're being passed the data from the view that contains them.
Re:How we do Vue: one year later (2017) by jaxn on Monday March 18, 2019 @09:29PM (#19427256)
If you use GraphQL, then Apollo and it's local cache are a pretty amazing alternative to VueX
Re:How we do Vue: one year later (2017) by Smithalicious on Tuesday March 19, 2019 @05:04AM (#19429172)
What exactly is your issue with props?