292 points · by mxstbr · 8y ago · 123 comments
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 was so easy to switch to it.
Transition from vue1 to vue2 was really simple. I'm sure the same will be true for v3.
I hate this misconception and wish it would just go away.
If you're referring to Create React App, it uses Webpack - just preconfigured so you don't have to fiddle with it before you start building.
The other comment gives a perfect example and there are a few tutorials (although I do agree not very mainstream) that teach React without JSX/Webpack/Babel/etc.
edit: You are correct that you need transpilation for JSX but you don't need JSX for React. The confusion of JSX/React sounds eerily similar to how newbies confused jQuery for JS.
Unfortunately it uses ES6 features. There's no ES3/ES5 demo without JSX -- https://reactjs.org/docs/react-without-es6.html uses JSX
But maybe I just sucked at vue.
If you did Ember or Angular1, Vue is much easier to grasp.
I'm a React fan, yet I really applaud all the nice stuff which is coming in Vue 3. Well done.
I looked it up before writing this comment, and apparently Vue introduced this in June 2018. Case in point of this comment thread :)
Lol. Writing JS libs is not research.
Currently the architecture forces you to import the Vue object entirely , has Vue under the hood isn't really modular...
With 3.0 Vue has taken the typescript way and is using packages , similar to angular , it looks absolutely awesome to work with now.
I really hope class based components will be supported natively without compiling or transpiling.
Working "out of the box" has always been part of Vue philosophy , I really hope this continue.
This is really a big release , but it's still sad to see the 3.0-alpha branch is not visible on GitHub , i really would have loved to have a look at it.
So you do...
<div id=users>
<a v-for="user in users" :href="'user/'+user.id">
{{ user.name }}
</a>
</div>
<script>
let userList = new Vue({
el : '#users',
data: { users: users }
})
</script>
...to make Vue render the list of objects.This is the only thing I ever use these frameworks for. Everything else I think I can implement in a better, leaner way myself. So I wonder if I should switch to a template engine instead.
What is the next most basic/common usecase for Vue?
My rule of thumb: if I need to do more then a trivial amount of DOM manipulation then I will use a framework, because otherwise I will end up writing my own anyway (which I can easily do) which wastes development time.
For projects with several developers a framework can help maintain common coding style and reduce ramp up time for new hires.
Also, good frameworks come with nice tooling that make for more productive development. For example, Vue + Vuex and the Vue browser plugin are great for inspecting the state and observing state transitions.
An example of my use case: I have a non-SPA app that receives various data via Websocket and the view is immediately updated. Several components take this same data and render it in different ways. Vue is excellent for this. I still use templating on the server side for the basic page structure.
Would be interested to see how you would implement that.
Vuex code as per docs to create state.stuff and mutations.update_suff() then in main Vue instance
mounted () {
this.$socket.subscribe(‘stuff’, data => {
this.$store.commit(‘update_stuff’, data);
});
where $socket is a subscriber client I wrote wrapped as a Vue plugin.Then inside the components
computed () {
stuff () {
return this.$store.state.stuff;
}
}
then use stuff as in your example.So very simple, and nothing that I couldn’t do without Vue but it takes care of the boring DOM manipulations and using the browser extension during development I can watch state change (which becomes interesting when there are multiple subscriptions with data combined).
If the data is ready to render while still on the sever, I do so.
Thank you for clearly talking about why you'd use Vue and when you wouldn't. It's this sort of experience-based knowledge that I often lack.
I'm currently writing basic (very basic!) node stuff intended to further my understanding of Kubernetes: accessing a database, talking to a redis instance, etc etc. It can be bewildering trying to navigate the "oh-so-easy" basic examples of different frameworks and compare their different features.
Hm, that sounds like I'm asking for help, which I'm not - I just want to give an example of why your comments were so helpful to me!
I guess what other sites save on re-rendering html, they lose multiple times on bloated code.
However the majority of sites these days use some form of SPAs.
Also under a second is a very low bar to strive to. a fast round trip to the server is 100ms. A reasonable one is somewhere around 300ms. Displaying effects to changes is often under a millisecond in SPAs and is basically impossible to reach in Multi page applications.
This lets you split your interface into more isolated components, and makes you free to use different framework depending on the type of interaction your page needs, as well as be able to update your site progressively.
React/Redux hasn't been around long enough for its best practices to solidify in the general industry so you'll often find that companies that picked up React have a hodge-podge of incorrectly used technologies included because they didn't know the use case for Thunks vs Sagas, how to use Reselect correctly, whether to store any given state in Redux or a Container, and so on.
Also, in those cases a few extra seconds for the initial load or the general size of the application don't matter. It's all better than your average Swing application ("Challenge accepted", said the Electron developer).
Although this isn't something contemporary frameworks seem to aim for (ExtJS is dying, and that's good), you get close enough to desktop UI development with Vue/Vuex/Ant Design, Angular/AngularMaterial or React/Material-UI/Redux-boilerplate-reducer-of-the-week.
The point of using Vue is data-binding with reactive models and components.
For your use case I agree Vue is overkill. A templating engine should be enough.
- TypeScript
- Double the performance
- Half the size and memory consumption
- New reactive system that supports classes a la MobX
- Class based components
I've been using Vue for a couple of years and I'm very excited about this new release.
Been using Vue 2.0 for personal projects and Aurelia for a big work project over the past year and I have to say I am very happy with both. Personally I prefer the single file components in Vue but the class based style of writing them in Aurelia. Seeing these two things converge in Vue 3.0 together with the performance improvements looks very promising.
*Not sure that under the hood Vue 3.0 works the same way as Aurelia but the mentioned points in the slides lists array index / length mutation and later the observable function are familiar from Aurelia.
Do you reckon we'll ever see Typescript support in the non-jsx templates? I do really like vue templates for e.g. if-conditionals. I really don't like using ternary operators for template logic. And then the alternative being to hoist things out of the single JSX template breaks make code less linear to read which kinda sucks
But you can indeed create small inline components in .vue files.
There are different approaches: https://codewithhugo.com/writing-multiple-vue-components-in-...
...
components: {
"inline": {
template: `
<h1>My inline subcomponent</h1>
`
}
}
...No problem: https://www.youtube.com/watch?v=l3GHggI3_z8
As you can see, the're quite a few nested components in a single .vue file.
Rewriting a big project from scratch is often used as something to brag about: "Look at all the hard work we accomplished!". Except in software what matters is correctness and efficiency, not the age or the code or the size fo the rewrite. Rewriting "from the ground up" is throwing away years of bugfixes[1].
Maybe this new version is fine; I'm only suggesting that big re-implementations should be seen as an unknown risks, and that "carefully refactored problematic areas of the code" is something worth bragging about on a slide.
[1] https://www.joelonsoftware.com/2000/04/06/things-you-should-...
Not necessarily. Sometimes it means "our old code was such a mess no one could make any sense of it" :)
I use flow because I am interested in soundness, have had a few issues with it, but nothing has suggested to me that typescript is more maintainable.
No matter how awesome you think whatever framework is, this is a terrible, terrible experience.