r/javascript • u/[deleted] • Nov 03 '16
Vue.js is the most trending framework of github. 117 stars per day
http://bestof.js.org/tags/framework/trending/this-month40
u/Zequez Nov 03 '16
TBH it looks more like Angular that React.
8
12
u/Savageman Nov 03 '16
Your comment just made me realize that both React and Angular people can grasp and use Vue, and that's probably why it became so popular! :)
0
Nov 03 '16
[deleted]
1
u/Savageman Nov 03 '16
I probably mis-worded that. If by grasp you mean understand the big picture when reading the code, then yes. I was more thinking of being capable of writing a functional app without looking too much docs. I know React and I know I don't feel capable of easily doing an Angular app, whereas Vue I want to try.
1
0
Nov 03 '16
[deleted]
5
u/BenjiSponge Nov 03 '16
Pardon my noob-ness, but isn't there two-way binding in Vue?
3
2
u/MisterGergg Nov 03 '16
You can add two way binding but the default preferred method is one way.
<!-- default, one-way-down binding --> <child :msg="parentMsg"></child> <!-- explicit two-way binding --> <child :msg.sync="parentMsg"></child> <!-- explicit one-time binding --> <child :msg.once="parentMsg"></child>3
0
3
u/Lhaer Nov 04 '16
Why would anyone replace Vue's default templating engine with JSX? Just because React is trendy?
10
u/zachrip Nov 04 '16
JSX really has nothing to do with React though. I believe React was one of the first libraries to make use of it but it's certainly not the only one now. This is because JSX compiled to Javascript just makes sense. What I mean by that is it's a very simple API that can describe a complex DOM well. It's easy to iterate and probably hooked straight into whatever Vue used after creating an AST for its normal templates.
TL;DR - JSX isn't just hype, it's just a really awesome way of describing the DOM in an easy to use way.
-1
u/icanevenificant Nov 04 '16
You failed to describe why jsx is easier and awesomer than the default Vue templates. I say because I'm genuinely interested.
10
u/zachrip Nov 04 '16
JSX is awesome because rather than using directives and things to do certain things like if statements and loops, you use real Javascript. This reduces the overhead of learning a new framework as well. Other than that, it's more or less the same as a templating engine.
0
u/icanevenificant Nov 04 '16
While it's true that it uses javascript it's still pretty particular in how you have to apply it. Looping for example requires you return a mapping of the array which ends up being quite verbose. I understand the appeal of using javascript but I'm not sure how much advantage that brings in real terms. The other issue I have with jsx is that you really need javascript developers to do, or at least implement, all the html and css and in a company that has limited resources that means hiring more expensive workforce to work on basic things like html and css.
2
u/__env Nov 04 '16
How is sticking an attribute on an HTML tag any more verbose than calling a function?
<div user-profile="ctrl.user">vs
<UserProfile user={user}>You have to use valid javascript to write directives, so I literally don't understand this complaint.
1
u/Lhaer Nov 04 '16
Using directives is much cleaner and the directives that come with Angular and Vue provide a lot of boilerplate code that you end up writing yourself when using JSX
3
u/__env Nov 04 '16
As someone who has spent a lot of time working in angular, I feel like it's simply not true that this
<div ng-repeat="user in ctrl.users">{{ ::user.name | lowercase }}</div>reduces boilerplate any more than this
users.map(user => <div>{user.name.toLowerCase()}</div>)Directives and components both reduce boilerplate in the same way --
<div users-list="users"/>vs.
<UsersLists users={users}/>Seems like the same idea to me.
There is a ton, a ton, a ton, of boiler plate involved in writing redux, but that has nothing to do with the view layer.
→ More replies (0)1
u/icanevenificant Nov 04 '16
I was comparing list rendering which is solved out of the box in angular and vue. Also, my complaint was that react is more verbose, ie. a lot of boilerplate. I've worked with both and find react a little heavy on the setup and boilerplate side. I love the single state tree and redux philosophy but think it's not the most productive library or framework if you include the react-router and redux.
1
u/__env Nov 04 '16
I guess I definitely agree that React is more difficult to work with in the sense that there is less magic -- you have to have stronger language fundamentals in React than you do in Angular, for sure.
There are definitely more moving parts in the React "Hello, world" than there are in Angular/Vue. That's for sure, but those moving parts also comprise basically 100% of the API surface area of the entirety of React. Angular might seem like it has a small surface area, but the second you're stuck troubleshooting some internal framework problem, wow, good luck.
So maybe Vue has eliminated some of this frustration by having a smaller feature-set than Angular?
→ More replies (0)0
u/Lhaer Nov 04 '16
What is the problem with directives? Under the hood is all JavaScript, directives are there just to abstract and nicely integrate JavaScript with HTML so you don't have to implement everything yourself. It's true that you don't have to learn a new framework (although templating engines are often very simple) but you have the overhead of writing basic functionality yourself with JavaScript
-3
u/Lhaer Nov 04 '16 edited Nov 04 '16
But JSX lacks so many features that a decent templating engine should have, you often have to use third party packages to do trivial things that the templating engine should be doing (e.g. classNames) or implement it yourself, and this is because JSX is not really a templating engine. React has NO templating system, that's one of the reason it's considered a minimal framework. The templating engine that comes with Vue and Angular can do the job just fine and I often find it much better than writing JSX and mixing JavaScript code with the presentation code. The first time I've found out about Vue I was wondering why everybody was so obsessed with React when Vue much simpler to use and just as fast, yet it was getting almost no attention at the time.
6
u/zachrip Nov 04 '16
WRT to mixing Javascript code with presentation code: stop thinking like that, it really is fine. What do you think happens under the hood with your angular or vue templates? If your component is doing anything but rendering the data it gets passed, you're doing something wrong.
-1
u/Lhaer Nov 04 '16 edited Nov 04 '16
What if you have to hand the component you wrote to a designer that only understands HTML and some CSS? That person will look at your React component and find it a mess. The presentation structure for a component must be separated from it's logic, I thought that was just common sense nowadays. On the other hand, if you hand a Angular/Vue template to a designer, he probably won't have any problems with it, since the templating engine is abstracting away all the complicated logic behind it, unlike React. And of course, for simple projects all your component will be doing is mostly displaying data it gets passed, indeed, but as your application grows, your components will start getting a lot more complex, at this point you have to separate all this logic from the presentation of the component.
3
Nov 04 '16
I don't know, the designer at our company had no issue picking up styling in JSX/React components, despite having no prior experience with it. And while he does most of the styling in CSS, he also admits using inline styles for simple things like
{ display: (state.isOpen ? 'block' : 'none') }is quite handy indeed.1
u/SaabiMeister Nov 08 '16
Ideally, you shouldn't think of HTML as presentation, but rather as presentational information structure, just the semantics.
Presentation should be purely in CSS.
The generated HTML should be just the minimal HTML necessary to mark the text semantically and nothing else. In other words, HTML is not something a designer should be creating.
I wonder if thinking of it this way would affect the convenience of JSX or a templating engine like the one in Vue.js.
2
u/jacobp100 Nov 04 '16
Some people might find the traditional templating engines to be limiting at times. My anecdotal edge-case example of this when I was trying to make this exact table using data in the form
{ column1Title: { column2Title: [...column3Data] } }.I was using Bootstrap where the styling does not work for nesting tables within
tds, so I had to use one table element and use old-stylerowspans.Using JSX, you can use two reduce functions to get this working. Neither StackOverflow or myself could not get this working with Angular’s templating engine.
2
u/syropian full stack @ felix health Nov 04 '16
Some people don't want the overhead of learning a new DSL and all its quirks, and since JSX is closer to "just Javascript", it makes more sense for some people.
I've gone both ways with Vue, my own personal project uses templates, but my latest company hackathon project, I explored using the
render()function and JSX only. Honestly, I'm not sure which I prefer. I kind of know all the ins and outs of Vue templates so they don't bother me, but I know a lot of JS purists who much prefer JSX. It's always nice the option is there.
13
u/HereWeGoHawks Nov 03 '16
Does anyone have a solid guide for vue js outside of the official guides? Looking for something that includes build tools and process
18
u/nosrek Nov 03 '16
Article: https://medium.com/@wilkerson_frank/building-web-apps-with-vue-js-2b298758a9d1#.8a7nm5h9w
Video: https://www.youtube.com/watch?v=cXyxLm8mMQg
I'm currently working on part two of the article (should be up in the next day or two). I'm also planning a short video on vuex (state management).
edit: I also have the project from the article series on github now, I'm currently doing a lot of refactoring on the project to help illustrate the topic of the second article, so they code is likely going to look a bit different in a day or two.
6
u/kirillsimin Nov 03 '16
Laracasts does a pretty good job. Don't know if there's one for Vue 2.0 yet, but there's a really good series on Vue 1.0
1
3
u/wishinghand Nov 03 '16
The Majesty of Vue sort of does that towards the end. Honestly, there's a pre-built Webpack boilerplate that works well.
Just
npm i -g vue-clithenvue init webpack myVueProjectand you're setup to develop.
12
u/jisaac89 Nov 03 '16
There are some opinionated issues I have with Vue that are scaring me away from using it as of now... mainly to do with how the templating reminds of angular with the v-for="todo in todos"
0
Nov 04 '16
[deleted]
3
Nov 04 '16
So why not react at that point?
3
u/LynusBorg Nov 04 '16
Because while using render-functions/JSX is very close to React, other things are quite different, most prominent of course the Data Reactivity, which React doesn't have (but can be added a bit mor verbously with MobX).
For a detailed (although naturally a bit Vue-leaning) comparison, which was developed in cooperation is Dan Abramov from the React core team, see here:
23
u/ThArNatoS Nov 03 '16
Vue is the first JS library / framework that clicks with me, it's just super easy to pick up and makes sense. I'm currently working on a small SPA web using Vue and it's been awesome so far :-)
2
9
u/BeerIsDelicious Nov 04 '16
Listen I know there are plenty frameworks de jour.
I've worked with vue for a long time. I've worked with react, angular 1 and 2, ember, meteor, and the like.
Vue is the easiest to get and up and running. With .Vue files it becomes super in a component sense.
With vuex we have the data binding cycle.
With vue router we have spa structure.
There are very very few things I dislike about vue and they started out on the right foot so hopefully updates are as painless as 1.x to 2.0
Awesome. Awesome. Awesome.
26
u/Krizzu Nov 03 '16
Used Vue if few projects and I must say, it way more easier to use it and achieve what You want than with React.
Although I'm not saying React is bad or something, I like it too, but for me now - Vue shines.
5
u/themaincop Nov 03 '16
How much time had you spent with React before? Did you end up plugging in a separate state management system for Vue?
4
u/Krizzu Nov 03 '16
Can't actually tell how much time I spend with React. Haven't used state management with it (Redux).
And no, haven't used separate state management for Vue either.2
u/themaincop Nov 03 '16
What kind of tools/features are you building?
6
u/Krizzu Nov 03 '16
I'm playing around realtime stuff using socket.io - to be most precise, I've created 2 real time chat apps - one build with react, other one with Vue.
And I must say that working with vue made it much more easier (and I make my opinion about Vue based on that)6
u/themaincop Nov 03 '16
Oh, very cool. If you have time I think the fact that you made the same real life application with both frameworks would make for a great blog post. Most comparison articles are very shallow.
2
u/Krizzu Nov 03 '16 edited Nov 03 '16
Oh, forgive me, I thought You're going to attack me saying something like 'Only that? How dare you say your opinion in public!'.
I'm not really good blogger, so I'll leave that to someone more talented, haha :)4
u/themaincop Nov 03 '16
Haha no definitely not, trying to get a better feel for if Vue is worth learning. It's hard to get a read on new libraries when all of the example seem very surface level, so I love seeing people's experiences of solving hard problems.
1
u/m0okz Nov 04 '16
Honestly you don't need to spend much time with Vue before you know if you like it. Just go through the getting started guide for simple examples of the syntax, and then look at the tutorials here: https://coligo.io/vuejs-components
2
2
u/MisterGergg Nov 03 '16
I've been working on a React project at work for 3 months and worked on a Vue project for about 9 months. I prefer Vue but Vue/Vuex and React/Redux are basically interchangeable stacks. Love them both, although for a noob I'd always recommend Vue. It is way easier to get productive with Vue, especially since they created the vue-cli for project generation.
1
u/m1sta Nov 03 '16
Have you tried riot.js? I find it to be another tier of easy again over vue.
2
u/Krizzu Nov 03 '16
Haven't even heard of it, haha. I'll stick to the Vue now, later on will try to test something else.
Thanks for the info!1
u/madwill Nov 04 '16 edited Nov 04 '16
Thank you for mentioning!
RiotJS is in my opinion the best template style javascript component framework out there !
I can bring RiotJS to my co-workers that never heard of component or web framework and they get it. It removes the entire hipster, "you should know that", fucking API and try to be as absent as possible from your work flow.
It didn't go and say : Let's create a whole new world but more of what's missing from this one?
Can't wait for next version!
Edit: Ok apparently i really have to try Vue.Js. I Will ! Man what an age to live in.
Side thing: Anybody tried Horizon.js.. OMG, reactive parametrized models out of backendless server with free indexing as you program ? WTF its amazing/scrazy, we're close to automating ourselves guys !! If we're lucky admins won't pick up on it for a few years so : Sitting on our ass, here we come!
1
u/m1sta Nov 04 '16
Is it still supported after rethink died?
I love the idea of things like horizon but I'm always a little nervous about the permissions model.
1
u/madwill Nov 04 '16
We run it with external auth and it goes perfectly for our simple realtime components,
Our system still highly rely on relational data but our live components switched to it and we're in love.
Basically it runs our webRTC signaling service sharing SDP offer, our whiteboard and interactive tools as well as live learning analytics.
We would never have that many killer scalable feature if that wasen't for horizon
And horizon will be supported. If not something else will take over. Its just RxJs once you know that API and some noSQL patterns you can get around
1
Nov 04 '16
Using it at work now, it's okay but the support and community just isn't on the same level. Would recommend sticking with either Vue, React or Angular.
I would only use it for the simplest of projects.
Also, don't agree with their "No semicolons!" view.
2
u/m1sta Nov 04 '16
I've literally never had to call on the community for riot. It's been easy enough to pickup and I've just had no problems.
I've used the other three too in the past. Much stronger community - which is good because you need them.
2
Nov 04 '16 edited Nov 04 '16
Never had to call on the community either. What I meant is that the framework itself doesn't have that much support behind it( people working to refine the framework). I think they got some more developers working on it recently though.
For small or personal projects, I think Riot is decent. As with anything else, use the right tool for the job.
EDIT: To be clear, I like the framework but like anything else, it does have its faults.
2
u/Capaj Nov 04 '16
Also, don't agree with their "No semicolons!" view.
What do you mean? You don't like that they are writing riot without semicolons? That might be the dumbest reason not to use a JS lib/framework I ever heard.
1
Nov 04 '16 edited Nov 08 '16
Where did I say not to use it because of that rule? I said that I don't agree with it.
It's a preference, if you want to omit semicolons, more power to you.
EDIT: Downvoting should not be used for disagreeing
2
u/Capaj Nov 04 '16
Okay but why would you mention it in a comment where you list reasons not to use riot.js. I do agree with the rest but this is out of line.
2
Nov 04 '16 edited Nov 04 '16
Because it's my opinion? It's a quick overview of a framework. If you read my other comments, I listed both it's pros and cons.
Out of line? For what exactly? Disagreeing with someone?
EDIT: missed a word
-2
Nov 04 '16
Same here. I was able to refactor my 70+ files in React+Redux to 100 lines in vue + 350 lines in a server html template. Amazing! And I did all that within a day whereas React and Redux took me weeks
12
u/fqn Nov 03 '16
Fuck me, I guess I'm learning Vue.js then. Based on the stars, and all these comments.
I just started using React in my last few projects, and React native for a mobile app. Wow ok, and there's a "vue-native" called weex, from Alibaba.
I guess I'm going to have to learn that too.
7
u/gaoshan Nov 03 '16
weex
Probably named after how long it has existed and how soon it will be superseded by a new variant, lol.
11
1
u/evilish Nov 03 '16
Haha, the great thing about Vue.js is that it's fairly easy to pick up.
The API is really well made. There's a vue-cli to help you quickly bootstrap an app.
Don't feel like installing vue-cli? Create a Codepen/JSBin/JSFiddle, add the library, reference a root element and off you go.
20
Nov 03 '16
[removed] — view removed comment
4
u/BeerIsDelicious Nov 04 '16
I hear you. I agree that learning a new framework won't go nearly as far as mastering one.
Find the one you're most productive at and be productive.
I'll put it this way. I'm a long time php / full stack developer. 13 plus years. That landscape doesn't move nearly as fast as the js one is now. But over those years it has. Finally a framework comes along (Laravel) where I finally think, here's the thing I would have built if I could start all over again. It just clicks with me. It gets out of the way while it does what I want it to do, quickly and unobtrusively.
That's what vue is to me. It's fast, way less obtuse than angular, as performant as react, and dead simple to implement.
Its like breathing a breath of fresh air and going 'ah this is what front end can be like'
0
u/fqn Nov 04 '16 edited Nov 04 '16
That's totally true. Unfortunately I'm a freelancer, so if I don't pick up new tools, I end up not being able to find work. It doesn't happen immediately, but I do need to be really careful about staying on top of things. Especially since I'm not always working on greenfield projects. I often have to jump into something that's already half-done.
I started on Rails, which doesn't have as many jobs now. There are way more jobs for Node.js. Also I started on Backbone.js, then there were more jobs for Angular, Ember, and React, and it will probably move towards Vue. But people don't seem to use Backbone much anymore.
For my own side projects I also enjoy learning new languages and frameworks, just to try things out. I wrote my last API in Go (Gin framework). Right now I'm using Elixir and Phoenix. Next time I want to try out a Swift framework (Vapor). I love Swift, have been using it for a few years now.
Ha there's even some progression happening in static site generators. I started with Jekyll, moved to Octopress, and now I use Hugo for new blogs and static sites. I love Hugo, it's super fast, and there's a lot of themes and plugins.
And for managing servers. Started with Chef + Capistrano, then moved to another company where I learned Saltstack, then Ansible, and then Terraform for infrastructure, and then the flood of containerization with Docker, CoreOS, Kubernetes. And then the Heroku clones, such as Deis, Flynn, and Convox.
Oh yeah, and even editors! I started with Geany on Ubuntu, and then everyone moved to Sublime Text. I spent a few weeks trying to become one of those vim masters but never really committed to it. I figured out how to quit though. Some colleagues tried to convince me to use RubyMine (an IDE), but I hated it, because it was too clunky and slow. And then Atom, which I used for a few weeks, but gave up because it also felt really slow and laggy. So I just went back to Sublime Text 3.
Anyway, back to programming languages and frameworks. I kind of agree that picking up new tools is pretty easy now. Especially if there's already some good documentation, and a lot of q&a on StackOverflow. Diving into the early versions of Swift was actually pretty scary, because there was very little help online, and I would stumble onto some obscure compiler bugs that no-one had ever seen before. A few times I had to just rearrange my code slightly to stop it from crashing.
One thing I've noticed is that the size and passion of a community is the only thing that really matters. If you have a lot of people contributing to fixing bugs, tooling, libraries, and support via chat or StackOverflow, then you can usually get anything done.
5
u/SandalsMan Nov 03 '16
Laravel is pushing Vue really hard, so I imagine a lot of hype is coming from PHP devs.
1
u/enyaboi Nov 04 '16
That's so weird bc client side has nothing to do with server side !
4
u/BeerIsDelicious Nov 04 '16
It doesn't but that's still the case. I'm a laravel dev and because of that got tied into vue but I wouldn't have it any other way. It's a great framework.
If or the record, I've tried angular 1 and 2,react,and several others. Vue gets out of my way and let's me build things more quickly than I've found with the others.
It has less to do with Laravel deck pushing it and more to do with vue being awesome.
1
u/chinchulancha Nov 04 '16
I'm in the same situation. Working with Laravel, and using Vue is a breeze. I'm doing a fairly complex calendar thingy with some wizards and such, and works great!
2
u/Yulfy Nov 04 '16
A question to any professional JS developer; is there a valid reason to switch from React to Vue if I'm familiar with the React ecosystem? I do mobile development (React Native), web development (React) and server work (NodeJS).
I asked this same question before moving between Angular and React and the advice was invaluable.
2
u/icantthinkofone Nov 04 '16
So I guess redditors, everywhere, will be switching to this one as if their lives depended on it. Cause you can't do anything today, at all, without vue.js. No one does. Anything else is antiquated.
3
u/captaintmrrw Nov 04 '16
Another JavaScript flavor of the month....
Actually I made a simple project with vue while back it. It was fun. I'd like to see more examples of applications with vue.
2
u/BeerIsDelicious Nov 04 '16
I just built a desktop application with vue, vueify, and electron. Rebuilt an angular / node website stack. It was so much better.
2
u/rusty_programmer Nov 04 '16
Holy hell!
I remember stumbling across this a while back and thought 'this will be useful later', then bookmarked it. I completely forgot about it. Vue is sweet!
1
u/samiheikki Nov 04 '16
Vue.js was the perfect option to create a JavaScript Guessing Game: https://github.com/samiheikki/javascript-guessing-game
1
u/GeorgeSharp Nov 04 '16
Question: If I prefer angular style MVC state management to React's Flux and Redux will I be comfortable with Vue ?
Or to put it another way what's the Vue.js way to handle state ?
2
u/syropian full stack @ felix health Nov 04 '16
Vue's official state management lib is pretty close to Flux/Redux. If you aren't using a state lib, it's still similar to React where it tends to be a mix of passing props, and/or emitting events through an Event Bus.
1
1
u/jacobp100 Nov 04 '16
Could someone give me a TL;DR on state/data management. In React, the defacto libraries are Redux or MobX.
Is the default state management sufficient for large-scale usage? If not, what are the defacto libraries people use? And how are they similar/different?
1
u/SkaterDad Nov 04 '16
There's an official state management library called
Vuexwhich is similar to Redux.It doesn't need anything similar to MobX, because Vue's built-in data reactivity stuff is similar (from what I understand). The official docs talk about it briefly.
1
u/yesman_85 Nov 03 '16
I wanted to create a small project with Vue 2 and it immediately started talking about webpack, guess V2 became quite a bit more complicated?
5
u/0x62047011 Nov 04 '16
That's not the impression I got from the docs. Webpack would be recommended for larger projects that need lazy-loaded single-file components, but it's incredibly simple to just drop Vue on your page and start developing. No need for even Grunt/Gulp/npm.
3
1
u/BeerIsDelicious Nov 04 '16
Even in small projects, if it's easy to set up and decreases the number of loads why wouldn't you? Setting up something with gulp to watch your app and recompile is trivial.
1
u/0x62047011 Nov 04 '16
I was specifically addressing a concern about the complexity involved with starting a small project, so I offered that they can start as simply as dropping the Vue file as a script on a normal HTML page.
If we all pretended the only way to make Vue apps was to go through the whole ringer, Vue will not become as popular as I would like it to be. In a world where the overall popularity of a framework can affect the quality of the documentation, how quickly questions are answered on StackOverflow, and even how bug-free the framework itself is and how long it's maintained, I want it to be as popular as possible, regardless of whether everyone is using it in the same way I am.
0
u/BrianTheCoder Nov 04 '16
To me it seems like you could accomplish the same thing by using native html onclick attribute, etc.
-2
0
Nov 03 '16
[deleted]
5
u/MisterGergg Nov 03 '16
Not a lot of frameworks have chinese documentation I'm guessing. But honestly, it's a great framework and worthy to stand with the giants of React and Angular. Evan You's a good dude.
1
u/chinchulancha Nov 04 '16
Alibaba or some other mammoth from China is using it, hence it's gaining traction there.
45
u/jodraws Nov 03 '16
I made a minesweeper game with no view in mind and later added VueJS 2.0 as the view.
It was super trivial and the result was great.