DEV Community

Discussion on: Why I Converted from Vue to React

Collapse
 
pauloevpr profile image
Paulo Souza • Edited

Your struggles with Typescript in Vue really surprise me. I have been using Vue with the class API and Typescript for over a year and I personally find them a joy to work with. I use Vuetify too.

I also cannot complain about the lack of type check in the templates since Jetbrains IDEs offer the same intelisense in template as it does in script (the typo example you demonstrated would appear as an error in my IDE). Not only that, I get the full power of refactoring offered by Typescript - renaming, extracting, referencing, etc - and that includes Javascript code in template as well.

Obviously, your experience is likely to be different if you use VS Code with Vetur which I personally believe to be a poor plugin (with all respect to the Vetur developers).

I also dont see any black "magic" with the way Vue handles things. Using the class API, the 'this' basically gives you access to functions defined in the base class, which is a very common approach in OOP in general. Also, $emit() is just a function that happens to be prefixed with the $ symbol for identification purposes. The $ symbol itself doesnt do anything special.

I also worked with the Vue Composition API plugin for Vue 2 and I had exactly the same pleasant experience using Jetbrains IDEs.

I personally find JSX the only real black magic in the entire javascript ecosystem. I have come to believe that JSX is the best thing to use if you intend to scare away new developers.

Collapse
 
anuraghazra profile image
Anurag Hazra

Hi Paulo, can you clarify why do you think JSX is the only read black magic in the entire js ecosystem? i'm planning to write a article about JSX so i wanted to know your opinions. why JSX is black magic to you?

Collapse
 
pauloevpr profile image
Paulo Souza

Black magic is not the right wording. What I mean is that JSX is not standard. If you look at Vue, it is essentially standard Javascript and HTML (with custom attributes) that can be understood by any web developer. JSX on the other hand is this weird and unfriendly mix of HTML and Javascript in the same code block.

There is nothing wrong with having custom syntax that requires a compilation step. Typescript falls into the same category, and I love it. I just don't like JSX cause it looks terribly ugly.

Thread Thread
 
anuraghazra profile image
Anurag Hazra • Edited

Okay let me go line by line and give my opinions :)

"What I mean is that JSX is not standard" ?? facebook.github.io/jsx/

"If you look at Vue, it is essentially standard Javascript and HTML (with custom attributes)" - i don't think vue, sevlte, or angular's templates are in any ways valid html markup

"that can be understood by any web developer" - JSX is way simpler to understand than vue's template, if i ask you "how does Vue's v-for directive work" can you answer it in simple words? but if i ask you "How does jsx loops works" i can tell you the answer "JSX is javascript so we can just use Array.map to map out the childrens directly in the template"

"JSX on the other hand is this weird and unfriendly mix of HTML and Javascript in the same code block." - JSX isn't a mix of HTML or js its Just javascript. it represents Tree like structures and we use it to build up the virtual dom.

"I just don't like JSX cause it looks terribly ugly." - well, personal preference :D

That's all. :)

Thread Thread
 
pauloevpr profile image
Paulo Souza • Edited

Needless to say it all comes down to preference since you could use any of these frameworks to build most web apps.

JSX is not just Javascript since it has markup in it and there is special syntax to separate markup from the actual js code. If it were just Javascript, it wouldn't need a special compiler in the first place. This is more than obvious.

Anyway, tools are just tools. Languages are just languages. Pick whatever gets the job done.

Javascript will die some die, just like Vue and React will die too, just like the almighty Jquery is dying just now.

As a developer, what matters to me is to spend my time getting the job done rather than advocating in favor of a particular framework.

Btw, I develop frontends using Angular, React, Vue, XAML, Blazor and vanilla javascript/html. As I said, they are nothing more than tools.