News for hackers. Stuff that matters.
Re:Why I left React for Vue by ng12 on Tuesday December 25, 2018 @10:20PM (#18760264)
But it's a lot of syntactic sugar. There's a second, stringly-typed language embedded in your HTML template.
Re:Why I left React for Vue by mattigames on Tuesday December 25, 2018 @10:28PM (#18760286)
The only reason for it to be "stringly-typed" is that your IDE doesn't support it.
Re:Why I left React for Vue by nv-vn on Tuesday December 25, 2018 @10:40PM (#18760343)
At the end of the day, it's much more of a hack. The IDE having to guess at what the string does is ridiculous to me, and it's just a ton of extra work for the person who wrote the IDE for no real reason. And now if you want to embed a string inside you need to switch quotes. Plus formatting gets super weird if you have a multiline condition. It's also super confusing for new users. There are so many issues I see with that design that I can't begin to understand why someone would argue in favor of it.
Re:Why I left React for Vue by lucidone on Tuesday December 25, 2018 @10:46PM (#18760363)
A lot of people are familiar with it (and that style) via AngularJS. It may not be as pure, but it's what they know.
Re:Why I left React for Vue by mattigames on Wednesday December 26, 2018 @12:42AM (#18760799)
An IDE doesn't have to guess anything, if the string is preceded by v-if then is code, that's it. Pretty much how a string literal inside eval() could be parsed as code.
Re:Why I left React for Vue by nv-vn on Monday December 31, 2018 @05:09PM (#18797358)
What if another library uses v-if? Or there's no library loaded at all? What if I just wrote a new library that uses c-if? I imagine most IDEs approach this by looking at the string and trying to guess whether it's HTML code or not.
Re:Why I left React for Vue by ng12 on Tuesday December 25, 2018 @10:31PM (#18760297)
It's still stringly typed even if someone wrote an IDE plugin that tries very hard to make it safe.
Re:Why I left React for Vue by orf on Tuesday December 25, 2018 @10:36PM (#18760320)
So just like JSX then?
Re:Why I left React for Vue by ng12 on Tuesday December 25, 2018 @10:44PM (#18760355)
No, because JSX is a 1-to-1 mapping to React.createElement, it's actually just syntactic sugar. There's no variable binding or evaluation.