Live data from Hacker News

Vue.js 3

github.com

201–210 of 308 posts

Re: Vue.js 3

#201

if this means no more Vuex, i'm all for that. that extra abstraction layer never proved useful to me.

Out of curiosity, how do you handle data needed by tons of components at different tree depths (info about the current user for example)? I don’t always reach for Vuex, but when an app reaches a certain size it sure beats passing every bit of common data down through the entire tree, as I find you quickly hit a point where you’re passing data to components solely so it can pass it to it’s children.

It's funny I still have never really understood the case for Vuex. So far I have built decent complexity apps just by having a global reactive object that all components link to directly in their Vue data and I have yet to hit a problem. I see huge writeups and design patterns all suggesting I really need to use a state management library and I'm waiting for the day the penny drops and I realise what a mistake I've made but so far everything just keeps rocking along .... what am I missing?

(I get that there are some nice features like time travel debugging etc but none of them seem outweigh the giant additional complexity of routing every single state change through 1-2 extra layers.)

Re: Vue.js 3

#202
post #81
post #37

I just started vue 3 and its incredible compared to my experience with react. Way to go Vue team!!!

> and its incredible compared to my experience with react Could you expand on this a little more? What is it specifically that makes it incredible compared to React, in your opinion?

For me and my team, it hits the right balance between Angular's structure and React's no-structure. We can use it for small apps within a server-rendered website, or larger SPAs.

I can hand a project to a junior dev and not have to explain project structure or patterns, nor worry about things going off the rails. Generally, after getting a feature working, most of the feedback I'll need to give is "break this 300 line file up into 3-4 smaller ones". Great ESLint rules provided by the Vue team really help with this.

With Vue 3, with the two APIs, I know that I'll be able to hand a feature off to a developer of any level and know they can accomplish it however it makes the most sense.

I can also jump into a legacy Vue app built by another team and have no issues getting oriented. In my experience with React, I haven't seen the same router configuration twice. Most React projects I've inherited feel over engineered

On a more meta level, I think the single-file API its a much better mental model than React's. Your HTML is still just HTML, and your styles are CSS or Sass, or whatever you choose.It's why I preferred AngularJS over the others at the time.

Re: Vue.js 3

#203

Why is IE11 support still important now? I can't find exact stats on it, but it seems <2%. Surely projects which still want to support IE11 could still stick for a while with Vue2.

I was surprised that became a feature of Vue 3, as well. I was hoping they would drop it, assuming you could just use Babel + Polyfills to get it to work if you really needed it.

Re: Vue.js 3

#204
post #182

Earlier quoted context omitted.

I'm not sure about React's capability with this, but Vue can very easily run with no build stage. You can load Vue from a CDN and use a couple lines of JS to point it at a DOM element in your app. Then you can write a plain JS Vue object (what goes inside the tags in a .vue file), and all this logic will apply inside the element you pointed it at. You can also write components, although that gets a little clunky with…

React can be run from a single file from a CDN, and used without a build stage. Only catch is you don't get JSX. While by today's standard some people might consider that unacceptable, it was a fairly common way to use it when it was new (because relatively fewer teams used builds for JS back then, and JSX was far from being widely accepted). My first year of React development was without JSX even though we DID have…

React has been able to use jsx without build forever, here is a modern take: [1]

The babel script is huge but it might be an option to get the ball rolling on a big upgrade.

1. https://medium.com/@to_pe/how-to-add-react-to-a-simple-html-...

Re: Vue.js 3

#205
post #107

Earlier quoted context omitted.

The market also isn't as volatile as people make it out to be. The top most used js frameworks (React, Angular and Vue) have been in the top spots for 5 to 7 years now. I guess the market might as well be settled. Of course there are some new comers every year, but they don't enjoy a large market share. Hell, I've not even seen VueJS used once in any serious project in the industry. React and Angular are here to stay…

I’ve deployed a number of applications using Ember’s (Octane) and will continue to use that over React, Angular, and Vue for as long as these other frameworks continue to prioritize fp zealotry over getting shut done.

What do you mean 'fp'? Ember was quite literally one of the worst experiences ever. Not having javascript expressions in handlebars is literally excrutiating. I'm so glad I never have to use ember, ever, ever again.

Re: Vue.js 3

#206

i learned vue2 3-4 years ago. should i learn vue3 or svelte instead?

If you know Vue 2, Vue 3 will be easy to learn, as well. There are some more advanced features you can choose to use if you want, but I guarantee you could pick it up really fast. This isn't an AngularJS -> Angular sorta change.

Also, give it a few more months before building anything non-trivial. Some of the more popular libraries for Vue 2 still need to up updated for Vue 3 (vue-router, vuex, for instance).

Re: Vue.js 3

#207
The announcement talk was nice to watch, however, it was technically void of any of the implementation details.

It's interesting to me that they did not consider the approach of pushing more work to the compiler and less to the runtime in the manner popularized by Svelte. I wonder what the trade-off between their current rendering approach and the Svelte-based approach are?

Re: Vue.js 3

#208
post #82

Earlier quoted context omitted.

Kind of -- reactive() lets you declare multiple values at once, and you can read the property directly. ref() is for single values, and to get at the actual VALUE, you need to use "myRef.value" const state = reactive({ msg: "hello", count: 1 }) state.msg // "hello" const msg = ref("hello") msg.value // "hello" Though when you use ref()'s in templates, it will bind to .value for you.

I find myself using `const state = reactive({...})` exclusively now. It's just way simpler (read:less mental overhead). But, I've only been using the composition API for a short while now. Do experienced Vue devs actually use both regularly?

According to the vue discord where I asked a lot of composition API questions, pretty much people use ref exclusively. It's much more explicit in your `use*` composition files when you have to call .value. It's rare to me to export a very large object of keys, and I have yet to use it yet.

Re: Vue.js 3

#209

Earlier quoted context omitted.

Why can't React do the same?

React and Vue can both be used directly with script tags, however the biggest difference is that React uses JSX while Vue uses HTML templates (but also supports JSX). 99% of the time, HTML is easier and faster to write, with the built-in directives providing all the functionality you need. More importantly though, HTML can be generated by every single server-side framework, and this makes it very easy to have server-…

That's exactly right and this is a much underrated capability and I think it's the point being missed by those saying "well if you do XXX you can include React with a script tag too!"

Re: Vue.js 3

#210
post #200
post #176

Earlier quoted context omitted.

You can do the same thing with React though, you can arbitrarily render a React root anywhere, and an arbitrary number of times on the same page. For instance, I work on an app that was originally written in Backbone / Marionette, but I was able to write generic connectors to allow us to drop in React at any point in the tree. Similarly, we can go back to Marionette / Backbone at any point in the tree. It's made grad…

React is a quite bit more all-in than Vue though. For example, an old app I'm aware of has HTML generated by JSP with its own convoluted maven build process and uses a mix of AngularJS and jQuery to hydrate client-side functionality on top of it. The development workflow is a draconian exercise in acrobatics through remote desktops and VPNs in really old laptops (because "security" and unions). Vue has similar hydrat…

I don't know if "from scratch" is really a fair statement. React accepts HTML in the render function, so the only thing you'd need to do is modify the variables to match JSX's variable syntax, which is exactly what you'd have to do with Vue.

I think it's all pretty much the same deal. You might argue Vue's template syntax is closer to HTML than JSX is, but that doesn't really feel like the major issue when slowly refactoring a large application.

Post reply on HN