Vue 3.0 Updates [slides]
docs.google.com
docs.google.com
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.
Personally, I don't find the function-call format that "annoying", and I think it presents some advantages neither JSX nor template strings have, along with some disadvantages (it's more verbose, like you pointed out).
The only time when you won't really have access to a tool chain is for quick demos with just an html page and a script tag (if you don't want to pull in babel as a script), but most online tool allow jsx too now anyway.
Not recommended for large projects in production (but then I'd be using webpack or similar for large vue projects too), but it works pretty well (and surprisingly fast) for quick experiments.
In this lesson I cover JSX:
https://github.com/kay-is/react-from-zero/blob/master/02-jsx...
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.
JS was not created for JQuery, and you can not used JQuery without JS.
When I say JSX was created for React, I mean that it was created to be a part of the design of React. Meaning they both first came into broader public awareness at the same time, together, and have continued to be promoted as two independent parts of a single system.
Unfortunately it uses ES6 features. There's no ES3/ES5 demo without JSX -- https://reactjs.org/docs/react-without-es6.html uses JSX
As an aside, is that really a problem these days? All modern browsers now offer comprehensive native ES6 support. Unless you still need to support older platforms like IE or some of the legacy mobile browsers, it's mostly a non-issue.
What's missing from any recent version of iOS Safari, though? Anything from 10 upwards supports pretty much all of ES6 with very minor exceptions, AFAIK. Even features from more recent versions of ES tend to be supported quite well quite quickly in the era of self-updating "evergreen" browsers.
isn't this just a little bit disingenuous
But maybe I just sucked at vue.
If you did Ember or Angular1, Vue is much easier to grasp.
But I probably wouldn't look too much into React if I wasn't forced to do it in a project 3 years ago.
Not really related but forms really are the most painful thing to handle in all those frontend frameworks, it's driving me insane how much work has to go into them when it's dead simple with a backend framework (eg Symfony/Django)!
Which IMO is simpler to understand as a newbie than Redux. Maybe because it had the luxury of coming after Redux/similar projects and underpinning a simpler parent framework.
You can still use the function prop pattern in Vue but it doesn’t make much sense when event emission is so much simpler to reason about.
This is where I've found Vuex is a life saver for reducing complexity, organizing state in a seperate area, and having a consistent interface for accessing/mutating data without a tangled web of events and functions across multiple files/layers.
Action handler gets data, does business logic stuff, sends result off to reducer that publishes the data back to the UI layer.
Online explanations of this suck.
On the other hand, redux's reducers are harder to visualize at the beginning. Until you learn how the reducer works, every reference to "reducer" leaves you slightly confused.
I visualized redux's better with a simple example. It helps you to see how state and reducers interact.
All state was owned by the master MCU, slave MCU sent messages to the master requesting changes of state, the entire state for the slave CPU was then sent over with the requested changes.
Even what UI screen was shown was handled this way.
I was much more junior then, so the entire system wasn't event driven, all state was transferred every 33ms (iirc).
Redux is moderately more complex than that system, although my system was built in pure C and involved interop between C and C# running in an interpreter.
If you've got any specific suggestions for improvements, please let us know! I'm always looking for ways we can make the docs better.
As a side note, React is separate from Redux, and Redux is definitely not tied to React. Here's a recent post about a team that opted to use Redux with Vue: https://snipcart.com/blog/redux-vue .
Specifically with Redux, I would suggest clarifying stuff around reducers and possibly renaming them. As is, reducers sound like “a monad is a monoid in the class of ...” Vuex specifically does a very nice job of calling their equivalent thing “mutations” which is more intuitive.
My visualization of Redux/Vuex is basically an application of the event system to state management. Instead of manipulating global.state.foo directly, you ask the system to change the value of foo and a callback does it. A simple explanation like that from the start with some examples of benefits of it would be really helpful.
Also, Vuex has a less strict but more usable idea of not having to import actions. You just refer to them as strings.
Also also, examples of XHR/promises handled by Redux especially with error handling all the way from “server returned 404/400/500/etc.” to how to hand that off to a UI element would be helpful. Takes way too long to discover the right pattern for action returning a promise.
The naming doesn't help.
"Reducers" is just so academic. Maybe a term like "publishers"?
Of course passing data by props instead of receiving a lambda is a bit of a different paradigm already. Takes some getting used to.
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?
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.
I guess what other sites save on re-rendering html, they lose multiple times on bloated code.
https://news.ycombinator.com/item?id=18476247
While 30s is off the chart, I see bloat that needs multiple seconds everywhere. The new Reddit, AirBnB, the various Google tools etc etc.
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.
Do you have a reference for that claim? I very much doubt you are correct, but I'd be interested in seeing some stats either way, if they exist.
I'm not saying that React/Vue aren't important and drastically changing what's thought of as best-practices in web development... but just because everyone on HN uses a front-end framework for their websites doesn't mean "all websites" do it.
I disagree, based on my experience of writing a reasonably complex non-SPA application which very much benefits from Vue.
I also think the fact that Vue Router ships as a separate app further suggests SPA is just one use case.
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!
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).
<script src="/path/to/vuex.js"></script>
And then?What are mounted() and computed()? They look like methods of a class?
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
...
components: {
"inline": {
template: `
<h1>My inline subcomponent</h1>
`
}
}
...But you can indeed create small inline components in .vue files.
There are different approaches: https://codewithhugo.com/writing-multiple-vue-components-in-...
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.