Hacker News new | ask | show | jobs
Vue: We no longer have any plan of deprecating the Object API (github.com)
161 points by dtien 2553 days ago
10 comments

I have to admit - I had the same reaction that many people had when the function api first appeared ("what is this insanity and why are you breaking everything i love").

But I read through, checked out the new (simpler) example, read Evan's arguments about logical task grouping, and on a second read with a more-open mind, I actually kind of like the new syntax and am now looking forward to trying it out.

I'm glad they agreed to keep the object syntax around though :)

My favourite part is the re-usability of the functions it encourages and the fact it breaks up the core Vue into individual functions (instead of one big module with options) which means Webpack can tree-shake not only your code but Vue's, resulting in far smaller libraries.

Edit: After reading deeper it looks like the "lean" version of the library with full tree-shaking stuff is taking a backseat and they hope to provide some better library reduction in the future :/

> After reading deeper it looks like the "lean" version of the library with full tree-shaking stuff is taking a backseat and they hope to provide some better library reduction in the future :/

That's a bit of a shame. I know it's a bit more work, but I wonder if they could have added in a switch where the compiler knows whether its object syntax vs function component syntax where the tree shaking is expected.

Reading the comments here and on previous Vue thread, I see a nice example of psychological reactance at play. First, it was "You're going to replace the API? No no don't do this, don't force us to use this new thing that sucks over the old better one!". Now, it is "Oh, so you're not going to replace the old API? Come to think of it, the new API is a really nice idea, has some pretty useful concepts in it!".

:).

Are you sure that both complains are being made by the same person? Vue is a popular project, and unless an idea is backed unequivocally by 100% of its user base then you'll always hear some users arguing in favour and others against.
People are always more motivated to criticise. I love the idea of the new API for a few reasons, but wouldn't just comment "yay, that's cool" on the previous post. I'm happy it stays as a plugin though.
I think the best part about Vuejs right now is how simple it is and everything just works!

A vue component is still as simple as {template: 'hi'}. You don't need webpack or any transliteration for it to work. Just drop the script tag like the good old jQuery and it's working! No wonder it has gained so much popularity as I don't think you can make it more KISS.

Transition from vue1 to vue2 was really simple. I just hope that when the dust settles and things are finalized, Vue remains true to it's core of keeping things simple.

I keep hearing this "a vue component is still as simple as {template: 'hi'}". Genuine question: I've been using Vue for the last couple of months, is anybody actually using this in the real world? Instead of vue-cli apps with single-file components (which is the other argument often seen)?
I also am. I love the simplicity of vue api, but I hate vue-cli, webpack(it is good because it's configurable and extensible, but it's overwhelmingly complex, all the output formats are a pain to debug, I have never seen sourcemaps work in chrome developer tools) and single file components.

That led me to create my own architecture to scaffold vue apps, which Evan You seems to hate.

https://github.com/vuejs/vue/issues/8106

In this comment, I showcased some production apps running with this:

https://github.com/vuejs/vue/issues/8106#issuecomment-386064...

https://github.com/vuejs/vue/pull/8807

I have improved this architecture even further in new apps, but I hadn't time yet to update the "vue-generator" boilerplate.

I am. I wrote a bang-simple extensible blogging system several months ago using Vue.

I started very, very simple. I ended up with multi-component files. No vue-cli. Three files. A few hundred lines of code.

Works fine. Never had to touch it again.

Might I ask if you could open source it? I badly need dead simple Real World examples.
Sure. Hell I'll not only open-source it, I'll do a 10-minute video walkthru if I can get some coders to watch and ask questions.
If you upload it to YouTube, I'll watch and probably have a question or two for the comments section :-)
Checkout Gridsome too :)
I am on a reasonably sized project (which I didn't start but took over).

It's just an easier better way to enhance existing server rendered pages to include responsive elements without needing all the single page/routing stuff nor dealing with mass of jQuery binds and hand rolled data stores.

And best part is, Vue plays quite nicely with jQuery so can still use existing libraries and elements.

I am using it that way an app I wrote for our company. I do have a custom bundler that will make a minified file for production environment but it just runs the source files through “terser”.
Sometimes all I need is data binding.

And Rivets.js seems to be defunct.

As a TypeScript user who always disliked the object API and preferred vue-class-component, I feel a bit left out in the fallout of this. JavaScript users are always the loudest. IMO there is no clear, great option for people who are TS devotees. Again it feels like TS was an afterthought.

Will have to experiment a bit. Maybe it's possible to do something decent with some helper functions.

They've said improved TypeScript support was a major motivator for this new syntax, and for Vue 3 in general. It just doesn't look like class components.
Class components seemed to be the best bet with the issues introduced over the past 6+ months. Issues that have languished presumably due to work on Vue3.. Which looks like it's a ways off still?
I disagree. Overall v3 will be more TS friendly as they’re working to make the lib more functional and less reliant on JS syntactic sugar like classes, hocs, and mixins.
Don’t the existing and new apis have type definitions?

Why do you feel left out?

I started writing a huge post with examples from the RFC and how I'd like things to look, but it became too involved and large, and no one wants to read that crap. I'll just summarise it with that props are problematic, both the old-school ones (which don't use TypeScript types at all, instead uses its own ad-hoc type system `{type: ..., required: ..., defaultValue: ...})` and the rather horrible `(null as any) as PropType<{ msg: string }>` type annotations for complex types and the "TypeScript-only Props Typing" which is better but does not have a way to set default values that I can see. Oh, also all props are optional per default which is not what you want in a `--strict` TypeScript project (which should be any new project).

Generally it's relying strictly on type inference instead of interface declarations, which might make edit-time type safety work OK, but lack in error messages (spewing out complex inferred type definitions) and overall readability (much more easier to reason about an interface you wrote yourself).

Also, everything inside the setup function are just variables and functions, so your editor will colour/highlight everything the same, whereas in the class proposal, you have clearer separation between properties (props/data), getters (computeds), methods and even static methods. It's just less messy. Now, I get that classes don't work with React hooks, and the other reasons for dropping classes are rather sound, but I really think that whole setup "God" function is a massive eyesore. TypeScript isn't only about correct type inference, it's also about improved ergonomics, readability, and, pardon the pun, less typing (on a keyboard).

I guess I wrote too much again...

I'm glad they listened, and after reading more into some of the use cases there are times in which having this function api could be very helpful to group certain parts of the code together.

https://dev.to/stefandorresteijn/vuejs-is-dead-long-live-vue...

It was never definitive, just a proposition they had put forth looking for feedback on
I think the new API is great, I think the terms compatible/deprecated scared everyone
I was pretty worried, both by the deprecation of the Object API, and if the Vue team would listen to feedback on RFCs (and change parts if necessary).

Very glad to see that both points turned out well. I was really not looking forward to trying to find/learning yet another JS framework.

Glad they listened!
Kudos to Evan and the team for listening to the community. There was a big pushback against the RFC, which can sometimes be attributed to sticks in the mud.

In this instance, though, I do feel that the changes weren’t necessary. All API changes come with a cost, and I’m unconvinced that the benefits outweighed it this time round.

Glad this is a publicly funded small team project that responds to its users rather than trying to push developer agenda on everyone.
I'm just glad they listened.

In many ways Vue is a spiritual descendant of KnockoutJS (except cleaner because the web platform had moved on) and those folks where amazing for compatibility relative to everyone else.

Changing everything ever version is definitely not what I want from Vue, there are plenty of frameworks already doing that and it's just tiresome after a while.

All in all it's a decision I'm pleased they made.