Live data from Hacker News

Vue RFC: Expose logic-related component options via function-based APIs instead

github.com

211–220 of 253 posts

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#211
post #182

Python 3 vibes. Terrible decision. Our team has decided after seeing this to use Vue 2.x until we can move away from Vue. Extremely disappointed. Simplicity was Vue’s bread and butter. Literally the only reason to use it over React. Now what’s the point? We get it, you’re a smart guy who likes FP, quit punishing the rest of us.

I'm not a fan of this RFC but how can you make such as drastic decision at such an early stage?

Everyone's treating this "request for comment" as if it's an official declaration of the new API.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#212
We have a (currently) 50-60KLOC SPA that, in the past 8 years, has survived migrations from a homegrown backbone+jquery-based MVC framework into angularjs (starting from v0.9), then to componentised angularjs v1.5 with webpack and TypeScript, to a heavily deangularised (but still based on v1.7) app where we've removed all useless DI (it didn't even help testing) and made all angular services into pure ES6 (well, in TypeScript) classes imported as modules, with Jest and TS transpilation via Babel.

We also have our own Redux/Vuex-inspired uni-directional state management solution that uses immer under the hood.

The next step, largely motivated by the fact it's hard to find developers who want to work with older frameworks, is to convert the app into Vue from the inside-out using ng-vue as glue, and when all components are Vue, remove the outer angular shell.

So we have been tracking these proposals. The original class-based RFC looked perfect for us, since that was 95% matching how our current (class-based) components look like. Seeing it get abandoned was a cold shower, but okay, not the biggest problem. Our components are as dumb as possible anyway, and we have all business logic in services. It'll just be some additional manual text-wrangling work.

The new proposal looks okay. I guess, just as React hooks made classes unusable in React, they had to go from Vue as well (though honestly, I don't really see the fascination with hooks, but maybe that's because we don't do anything like the Hooks examples I've seen in our app). I do really like the idea of the reactivity system being completely separate from the rest of the framework.

I personally never liked the original JS-only API either, with the { props:, methods:, computed:, } etc. "separation" (commenters here call it "simple", but I think it's far from that), so in my Vue 2.x projects I used vue-class-component.

Overall, the motivations and reasoning in this RFC seem sound to me.

However, here I come to my three biggest problems I have with this API:

1) The fact that you have to return the render props from the setup() function. It's annoying repetition, and I foresee people forgetting to add a newly added prop here. It also makes the definition of the component feel procedural instead of declarative. You have to read/mentally run the setup function to know the shape of the component. Hopefully maybe you can notate the setup() function return type to match a TS interface without breaking editor support?

2) The fact that they couldn't come up with a better-looking way to declare a prop with a complex TS type other than `prop: (null as any) as PropType`. I guess I could make a noop generic helper function for this, though.

3) props are optional per default. I feel this is the completely wrong default for a TS project (mentioned as a consideration in the RFC though)

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#213
post #55

Earlier quoted context omitted.

I feel like I'm shilling a bit for React over here, but they are nearing two years without major breaking changes, and has been the de facto framework to go to for quite a while now.

It seems inevitable that hooks will be the only API 3 years from now though, and its already the case that all the new literature and examples are only going to teach hooks. Vue might maintain compatibility just as long but they've totally hosed their messaging on this judging from all the comments in this thread.

True, though as I said elsewhere: relegating the "old" syntax to a "compatibility build" is giving a strong signal that they will be deprecated soon.

But yeah, for now it appears they'll maintain compatibility well enough.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#214

Hopefully history will repeat itself and some clever dev will fork Vue 2.0 and create a new framework which has all the good parts of Vue 2 and nothing from this react inspired Vue 3 and all would be good again (just like Evan did when Angular went rogue)

I think it's inevitable that if EvanYou does betray us, we really could just have a community fork of 2 and 3. You can see the support exists in this thread, and let's be honest here, VueJS seems pretty good and complete as is anyways.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#215

Not a Vue programmer, but looking at the code, why is the example code using {{ count }} instead of standard JS interpolation like ${count}, and using an App.template block instead of just returning the template with the count and other params. E.g. why not just make it plain JS, and minimize framework surface? I could rewrite that example removing almost all of the "Vueisms", and it wouldn't be a single line longer.

Single File Components are converted to functions at build time (not run time) and that's the syntax for "string interpolation, but the variable is not trusted html". This protects against html injection.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#216
post #200

Earlier quoted context omitted.

I'm aware of that - hence the form of my previous comment. "This time it's different" though. The difference being: this here is radically less complex and unlikely to become much more. All this complexity in frameworks was always added in a vicious cycle, namely: 1. Developer looks at a component - they see complexity. 2. They don't know how much of it is due to the business logic being complex and how much is intro…

Are there any svelte tutorials/examples that specifically target vuejs users?

I haven't seen any, but as a relatively early proponent of Vue(as in: I was there when v2 came out), I found Svelte even easier to get into than Vue.

Anyway Rich Harris' presentation is a good starting point:

https://youtu.be/AdNJ3fydeao

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#217

Vue team lead here. There is a lot of FUD in this thread so we need to clarify a bit: - This API is purely additive to 2.x and doesn't break anything. - 3.0 will have a standard build which adds this API on top of 2.x API, and an opt-in "lean build" which drops a number of 2.x APIs for a smaller and faster runtime. - This is an open RFC, which means it's not set in stone. The whole point of having an RFC is so that u…

I don't get all the negativity. From a typescript perspective, this looks like a breath of fresh air compared to the component based API.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#218

Well that's enough to reinforce my switch to https://svelte.dev I want a JS framework simple enough that even hobbyist devs can understand in an afternoon. React syntax is an overly complicated mess; like reactivity forcing itself onto HTML. Current Vue syntax is neat, simple and clear; like HTML with added reactivity.

A JS framework that a hobbyist can understand in an afternoon is frequently, but not always, not a framework that works at cloud scale. I support all the choices you make, but there are those of us who have good reason to value useful complexity. <3

What defines "cloud scale" in your opinion?

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#219
post #138
post #122

Earlier quoted context omitted.

It's not a new feature it's a complete new methodology.

That's quite hyperbolic. Functional components have existed in React for a long time, hooks are just adding existing concepts (state and lifecycle operations) to them.

We will have to agree to disagree. IMO the compositional paradigm of hooks is radically different than using classes for example.

Re: Vue RFC: Expose logic-related component options via function-based APIs instead

#220

Earlier quoted context omitted.

Hopefully they recognise their niche and stick to it. I'm particularly interested in Svelte for compiling down to vanilla WebComponents to be used in P2P apps (eg Holochain) where you want the end users to be able to modify components themselves.

Svelte has supported compiling to custom elements for over a year.

Where are the docs for that?
Post reply on HN