News for hackers. Stuff that matters.
Re:Guide to JavaScript Frameworks by patientplatypus on Sunday January 21, 2018 @10:32AM (#16198396)
Reasons why Vue will rock your socks off

- Don't need to know jsx!

- Sane way of scripting puts the script in an object and each component is <template>html</template> <script>javascript</script> <style>css</style>

- Event buses allow sharing of variables between child components without either redux or pushing variables down one child at a time (finally!)

- v-for looping is saner than reacts mapping

- v-if allows v-if statements without renderIf component or multiple render statements in react (antipatterns boo!).

- two way data binding with vue-model

- native vuex with an index file that holds state sanely, rather than just having state held in each reducer as done in react

- Great documentation!

- Yay !

Re:Guide to JavaScript Frameworks by Klathmon on Sunday January 21, 2018 @10:48AM (#16198463)
Honestly I don't think Vue is better than React, or React better than Vue.

They are just different, and that's where a lot of the arguments come from.

For me, Vue is such a monumentally large step backwards. I loved React because there are no templates, there is no 2-way binding, you don't have the vuex style state handling. Using Vue is an exercise in frustration for me, dealing with all of the templating headaches that I was so happy to escape, needing to learn the "template pseudo language" which ties your hands in a way that I haven't found helpful. But this makes Vue no more wrong or worse than someone using tabs instead of spaces is "wrong" or "worse".

But for others, React is a nightmare because of those reasons. A friend of mine greatly dislikes the React paradigm, and was always more productive and wrote better code in a templating style. And I genuinely don't think it has anything to do with productivity or skill. Vue's style might be better at some things, worse at others, React is the same, but in different ways. They are both fantastic frameworks.

Re:Guide to JavaScript Frameworks by vanillaboy on Sunday January 21, 2018 @11:30AM (#16198618)
To me React is superior for a very simple reason.

There is a huge deficit of intermediate-advanced Vue tutorials compared to React. There are like 30 advanced-level tutorials on Egghead on React and like, what 3-4 advanced Vue tutorials (Nuxt, Nuxt and using Angular-like decorators to write proper classes instead of the 'it just works' vanilla boilerplate)?

Learning the ropes of Vue is easy. It's a go-to framework of the Laravel crowd for this very reason - you don't need to know Javascript much if at all, just learn some basic syntax and you're good to go for some basic virtual DOM magic.

Re:Guide to JavaScript Frameworks by _mrmnmly on Sunday January 21, 2018 @03:25PM (#16199793)
ekhem.. check this tutorial: https://www.udemy.com/vuejs-2-the-complete-guide/ <- that's the only tutorial You'll need to master vue that's not its official documentation. You know why there's not many more advanced tutorials for Vue? Because that one COVERS IT ALL - once You finish it You're basically Vue.js dev that will solve any problem related to it.
Re:Guide to JavaScript Frameworks by spikej on Sunday January 21, 2018 @01:42PM (#16199314)
Add to that tooling compatibility issues with TypeScript & Vue
Re:Guide to JavaScript Frameworks by CharlesW on Sunday January 21, 2018 @03:05PM (#16199699)
Mind elaborating? As of late, Vue's TypeScript support seems pretty nice.[1]

[1] https://vuejs.org/v2/guide/typescript.html

Re:Guide to JavaScript Frameworks by sasmithjr on Sunday January 21, 2018 @05:57PM (#16200595)
Unless I'm mistaken, it only really works well within a component. You don't get prop type checking in the component hierarchy.

Also, Vuex is very string-based, so you don't get payload or return type checking when you use Vuex. There are additional libraries that look to help this, but it's still an issue.

I could be wrong about any of this, but those are currently the issues I'm running in to.

Re:Guide to JavaScript Frameworks by mlsarecmg on Sunday January 21, 2018 @11:19AM (#16198578)
The points you've listed are the very reasons why i would prefer React actually ...

- JSX fixed all the templating issues from 10 years ago, i see no reason to go back to dependency injection, scope loss, arbitrary code-in-html expression and a semi-javascript accent

- Presentational view logic belongs to the controller while business logic is elegantly abstracted in React: view=fn(state). There's no point in ripping view creation from the presentational layer.

- Context and higher order components. Can't have those in an imperative architecture.

- v-for is not sane to me. Also odd, being forced to mix-in extensions for the simplest basics that go beyond the few presets Vue provieds: https://github.com/Krizzu/vue-for-range A React user doesn't solve problems by searching the internet for framework specific solutions, they import _ from 'lodash' and use _.range, like everyone else does.

- {condition && <div>hello javascript</div>}

- We have suffered through two-way data bindings with Angular already

- Vuex is not native. It mutates state by aggressively transforming state into setter/getters, with nasty edge-cases. Once Vue switches to version 3 using proxies, you'll maintain two incompatible codebases. React has Mobx, even though Redux is great. Also lots of lean and promising alternatives like Unistore.

- Knowing React you don't rely on documentation (though official docs are on point). It is simple enough to grasp it after looking at a view examples once. The api surface and cognitive overhead of React is a tiny fraction of Vues. Coming from Angular it is amazing that one month of learning and half a year of consulting docs turned into a week and a couple of months consulting with Vue. Yet, you can learn React fully in the shortest amount of time while simply remembering the few things you'd need to know. A generic round-trip, for instance the one at egghead, costs you 60 minutes total.

- http://www.npmtrends.com/angular-vs-react-vs-vue-vs-@angular...

Re:Guide to JavaScript Frameworks by hungerstrike on Sunday January 21, 2018 @12:05PM (#16198794)
These are exactly the same reasons that I think React is the best. Vue looks like it's going backwards compared to React. Furthermore, you get native mobile apps for free with React Native. Also, React has a much, much bigger community and bigger companies supporting it.
Re:Guide to JavaScript Frameworks by mlsarecmg on Sunday January 21, 2018 @12:13PM (#16198843)
Re:Guide to JavaScript Frameworks by buoyantair on Tuesday January 23, 2018 @09:53AM (#16213974)
wew dude o.o
Re:Guide to JavaScript Frameworks by Kiro on Sunday January 21, 2018 @11:48AM (#16198695)
I've used Vue for larger project and like it but the things you list are the drawbacks IMO:

- Don't need to know jsx!

But you need to learn Vue's template DSL. JSX is just HTML and JavaScript.

- v-for looping is saner than reacts mapping

- v-if allows v-if statements without renderIf component or multiple render statements in react (antipatterns boo!).

Strongly disagree!

- two way data binding with vue-model

I suggest anyone thinking of using two-way binding for anything to rethink their choice. There is always a better way.

Re:Guide to JavaScript Frameworks by dsego on Sunday January 21, 2018 @01:04PM (#16199117)
JSX is NOT just HTML and JavaScript! If it was just html I could write <label for=""> and not <label htmlFor="">, I could write <div class=""> instead of <div className="">. It's not even just javascript, or I would be able to write a simple if-else statement. JSX is a DSL, a minimal one, but still. I mean, you could say it's even worse, because those subtle differences can cost you hours of looking for mistakes.
Re:Guide to JavaScript Frameworks by hobofan on Sunday January 21, 2018 @02:09PM (#16199432)
> If it was just html I could write <label for=""> and not <label htmlFor="">, I could write <div class=""> instead of <div className="">

In case you don't know (and I also didn't until recently), those namings come from the HTML DOM Javascript API, and not from React. So having that naming in React+JSX is more a consequence of operating on that abstraction level, than a quirky decision of the React developers.

Re:Guide to JavaScript Frameworks by dsego on Monday January 22, 2018 @04:16AM (#16203028)
Well, if you're being pedantic, DOM is not HTML.
Re:Guide to JavaScript Frameworks by mlsarecmg on Monday January 22, 2018 @04:34AM (#16203111)
> If it was just html I could write <label for=""> and not <label htmlFor="">, I could write <div class=""> instead of <div className="">

for and class are reserved statements, hence htmlFor and className are the official api names, in other words they belong to the actual web-api spec, there's nothing arbitrary about it:

https://developer.mozilla.org/en-US/docs/Web/API/Element/cla...

https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelEl...

If you really dislike it, you can still use class and for: https://github.com/insin/babel-plugin-react-html-attrs

> or I would be able to write a simple if-else statement

{} evaluates to a ternary. You can use if, according to the spec that's what do expressions are there for.

    do {
        if (condition) <div>yes</div>
        else <h>nope</h>
    }
Though most would probably prefer the following for stylistic reasons:

    condition 
        ? <div>yes</div> 
        : <h>nope</h>
> because those subtle differences can cost you hours of looking for mistakes

These two things are explained in a single sentence, every tutorial eases you into it, the first thing that comes up once JSX is mentioned.

Re:Guide to JavaScript Frameworks by dsego on Friday January 26, 2018 @01:43PM (#16241738)
for and class are not reserved in HTML, they are in JS, but why would that matter for JSX?
Re:Guide to JavaScript Frameworks by mlsarecmg on Monday January 29, 2018 @01:34PM (#16259535)

    const { for, class } = this.props
Will crash. It's just a bit inconvenient (and inconsistent for beginners) having to write:

    const { for: forHtml, class: className } = this.props
Some react-like libs do allow it, but the dom api takes offcial precedence, so it's all fine. It's just that HTML in general was made without taking all the things into account we demand of it today. It wasn't even made for imperative inflating, so the dom-api faced the same troubles.
Re:Guide to JavaScript Frameworks by pitaj on Sunday January 21, 2018 @01:47PM (#16199337)
It is Javascript, but JSX brackets only allow an expression within them. Conditionals are statements in JS, so you have to wrap them in an IIFE or a `do`-expression.
Re:Guide to JavaScript Frameworks by orangecat on Sunday January 21, 2018 @02:10PM (#16199438)
I suggest anyone thinking of using two-way binding for anything to rethink their choice.

v-model isn't two-way binding in the AngularJS sense; it's just a shortcut for binding a "value" property and updating it on "change" events. See https://vuejs.org/v2/guide/forms.html.

Re:Guide to JavaScript Frameworks by chuckdries on Sunday January 21, 2018 @10:47AM (#16198454)
Seconded for Vue, I used it for a contract project for a year and was consistently blown away.

Gitlab sums it up for me "Vue isn't a buzzword, Vue is a workhorse" https://twitter.com/gitlab/status/928675879676497920

Re:Guide to JavaScript Frameworks by matwood on Sunday January 21, 2018 @11:24AM (#16198596)
> - Sane way of scripting puts the script in an object and each component is <template>html</template> <script>javascript</script> <style>css</style>

Each component I have in React is script + css. It did require some setup though.

> - Don't need to know jsx!

Except you need to learn the v- bindings. I prefer JSX and JS here.

> - two way data binding with vue-model

Two way data binding is a problem, not a feature.

Re:Guide to JavaScript Frameworks by pythonaut_16 on Monday January 22, 2018 @01:05PM (#16206435)
OP is slightly incorrect about two way data binding. Vue doesn't have two way databinding in the same way that AngularJS does.

Vue's "two way databinding", i.e. v-model directive, is actually just a syntax sugar that's equivalent to adding an event handler and a dynamic property on the value/text of the element.

Re:Guide to JavaScript Frameworks by naiyt on Sunday January 21, 2018 @10:38AM (#16198417)
> two way data binding

Maybe it's better in Vue than it was in AngularJS, but this seems like a downside to me.

Re:Guide to JavaScript Frameworks by chuckdries on Sunday January 21, 2018 @10:43AM (#16198441)
v-model is meant for use specifically with <input> tags, so your local component state stays synced with what the user sees. You can use it on components, but you're not meant to. In general, vue encourages you to avoid using two way data binding on custom components unless your component is a souped up input component, like a fancy date picker or something.
Re:Guide to JavaScript Frameworks by g_b on Sunday January 21, 2018 @10:45AM (#16198449)
> Don't need to know jsx!

You don't need to know jsx for using jsx. You only need to know html. You do need to learn something more with vue, you said so yourself, those v-for, v-if directives.

> each component is html.file, javascript.file, css.file

I prefer to only have one file per component so that I can just "import Component" and use it. With 3 files I need to make sure all 3 of them get loaded. Disclaimer: I do not know how Vue works.

The rest sound interesting.

Re:Guide to JavaScript Frameworks by Klathmon on Sunday January 21, 2018 @10:54AM (#16198489)
The one thing that Vue does great is exactly what you say you like about React (edit: not to say there aren't other things Vue does great, just that this is one of them). In Vue you have one file that contains the styles, code, and HTML for the component, all in their own HTML tags.

That means that there is a "blessed" solution for styling, that I'm afraid React will never have. Between "styled components", CSS-Modules, css-in-js, and tons of other options, many in-operable with each other. Styling is React's worse part, and it doesn't look like it's getting any better...

Re:Guide to JavaScript Frameworks by naiyt on Sunday January 21, 2018 @11:09AM (#16198540)
styled-components are actually really nice, so I don't think it's fair to say "styling is React's worst part". This seems like a more general criticism of React's agnosticism when it comes to so many things. React falls more heavily on the library spectrum than the framework one. It's rather un-opinionated about a lot of things: styling, state management, routing, code organization, etc. Definitely not something that's unique to styling.

On the one hand this offers a lot of flexibility to do things the way you want, but also makes the learning curve a lot steeper. Honestly I would love for somebody to build a more full fledged framework around React that makes most of the decisions for you. A sort of "good for 90% of use cases" setup. (I guess create-react-app is sort of like that? You still have to make too many decisions, I think.)

Re:Guide to JavaScript Frameworks by Klathmon on Sunday January 21, 2018 @11:13AM (#16198555)
I completely agree, but at the same time styling still sucks in React when it comes to using 3rd party components. Not to mention that with each way of doing it there are big tradeoffs (styled-components pushes a bunch of what I feel could be compiled before release to the client at runtime).

Most of the other parts of React are great with the freedom of choice. I can use a 3rd party component that handles it's state internally, or expects to be controlled externally, or uses or doesn't use JSX, or organizes it's code however it wants. But if I want to style it (which i'll need to do), I need them to support the method I'm using in my app, or have this very ugly and hard to support "bridge" between what I'm using and what they are using.

I'm not trying to be all doom-and-gloom, but it is a pain point for me, and it's not getting better in my experience, it's getting worse. It's not nearly bad enough to get me to switch away from React, but it's something I would like a nicer solution to.

Re:Guide to JavaScript Frameworks by naiyt on Sunday January 21, 2018 @11:19AM (#16198580)
Good point, I wasn't really thinking about styling 3rd party components. styled-components makes it sort of okay, but still feel hacky.
Re:Guide to JavaScript Frameworks by ggregoire on Sunday January 21, 2018 @12:07PM (#16198810)
You just listed all the reasons why people moved from Angular 1 to React.
Re:Guide to JavaScript Frameworks by jmschlmrs on Sunday January 21, 2018 @10:36AM (#16198409)
This sounds very much like Angular 1.
Re:Guide to JavaScript Frameworks by kowdermeister on Sunday January 21, 2018 @10:43AM (#16198437)
"Some of Vue’s syntax will look very similar to AngularJS (e.g. v-if vs ng-if). This is because there were a lot of things that AngularJS got right and these were an inspiration for Vue very early in its development"

https://vuejs.org/v2/guide/comparison.html

Re:Guide to JavaScript Frameworks by jmschlmrs on Sunday January 21, 2018 @10:50AM (#16198471)
So is it fair to say that Vue is for people that wish Angular had stayed on the V1 path and not diverged to be more like React for V2 onward?
Re:Guide to JavaScript Frameworks by lobo_tuerto on Sunday January 21, 2018 @11:05AM (#16198529)
No, I think it would be fairer to say that it's like if AngularJS and React had a child and named it "Vue.js".

Because in the end, Vue.js has stuff in common with React, like the virtual DOM (you don't see this in Angular 2+) and has stuff in common with AngularJS (the good parts).

Check this out: https://vuejs.org/v2/guide/comparison.html

Don't go thinking you are going to read a biased comparison, the Vue.js vs React section has the blessing from a core React contributor (Dan Abramov): https://github.com/vuejs/vuejs.org/issues/364#issuecomment-2...

Re:Guide to JavaScript Frameworks by rmrfrmrf on Sunday January 21, 2018 @04:44PM (#16200210)
As someone who had to use AngularJS for a while, just wait until those template directives get replaced in future versions to support random-use-case-17483 and force you to refactor a bunch of template code for literally no tangible gain. Then you’ll understand why using native JS to generate elements makes more sense.
Re:Guide to JavaScript Frameworks by mmargerum on Monday January 22, 2018 @08:18AM (#16204100)
The reason I prefer vue/vuex over react/redux is that I can mutate my days structures instead of pretending JS supports immutable data structures .