News for hackers. Stuff that matters.
Re:Front-end design, React, and a bridge over the great divide by tuesdayrain on Friday July 19, 2019 @12:36AM (#20476215)
I was initially a pretty big fan of JSX, but after using Vue it just feels like extra overhead. In my experience, parsing complex JSX in my head results in constant context switches depending on whether the specific parts I'm looking at are closer to HTML or closer to JS. And for the tasks I've generally been doing at work, there rarely seems to be a good reason to combine the two. If I'm trying to fix a bug for example, it's almost always clearly restricted to either HTML, JS, or CSS. And I really appreciate how Vue minimizes the amount of code I need to search through in those situations.
Re:Front-end design, React, and a bridge over the great divide by ergothus on Friday July 19, 2019 @02:15AM (#20476533)
I keep hearing all of these "Vue just makes more sense than React" converts, and I'm baffled. I recently did some Vue after doing React for a few years, and it felt like a major step backward. It felt very JSP - here was a different syntax that was HTML except when it chose not to be - managing data was done in a custom expression language, and I was left to figure out what scope a given value had. Need to loop something ten times? It's one tag with a special "v-for" property. Want do to that loop with a condition? Special "v-if" property, and is that evaluated in the scope of a variable created by v-for or not? No idea! And that's not even getting into the various parts a Vue component object has.

JSX is just javascript. It's HTML looking, but is ALL (not some) a wrapper to write a JS function that outputs HTML. Need to have a loop? Loop in JS. Need to have a conditional? Condition in JS. What scope? This is all a JS function, so the scope rules are all JS scope rules.

I have no idea if I'm a weird minority, or if I'm just running into more people that felt better with Vue than React, but I really don't understand why.

Re:Front-end design, React, and a bridge over the great divide by moksly on Friday July 19, 2019 @08:12AM (#20477934)
I don’t think you’re a weird minority. I work for a Danish city and we operate around 500 different IT systems. They are all slowly migrating to web, with some backend typically JAVA or C# and a JavaScript MVVM front. Only one of them uses Vue, all the others use React or Angular.

If you look at the job market around here, it’s 70% react and 30% angular with almost no Vue jobs right now. The ones listing Vue as a requirement almost all use React, who are willing to retrain Vue developers. It used to be more evenly distributed between angular and react, but it would seem that react won the front end war.

This is HN though, it’s not very representative of what goes on outside of Silicon Valley. Right now there isn’t a single Rust job in my country as an example, at least not in any of our major jobbanks. There are thousands of PHP jobs though. But if you took HN to be representative for languages, you’d think it was the opposite.

Re:Front-end design, React, and a bridge over the great divide by pjmlp on Friday July 19, 2019 @04:18AM (#20476992)
JSX feels like PHP and ASP all over again.

Apparently they aren't that bad after all.

Re:Front-end design, React, and a bridge over the great divide by Marazan on Friday July 19, 2019 @07:22AM (#20477664)
I hesitate to tell people. They are doing it wrong but if you write JSX like how we all wrote PHP back in the day then you are doing it wrong.
Re:Front-end design, React, and a bridge over the great divide by pjmlp on Friday July 19, 2019 @09:41AM (#20478544)
So how do you modularize content in separate files?
Re:Front-end design, React, and a bridge over the great divide by efdee on Friday July 19, 2019 @07:09AM (#20477613)
How can you say that? PHP and ASP were dumb text template processors. JSX creates object graphs. They are almost nothing alike at all.
Re:Front-end design, React, and a bridge over the great divide by pjmlp on Friday July 19, 2019 @09:40AM (#20478532)
Mixed content on the same file, looks pretty much the same, regardless how it is implemented.
Re:Front-end design, React, and a bridge over the great divide by efdee on Saturday July 20, 2019 @07:16AM (#20485163)
The problem with ASP/PHP (or at least, the one we are addressing here) always mixing presentational logic with business logic. Something you still shouldn't do, and React doesn't advocate doing so at all.
Re:Front-end design, React, and a bridge over the great divide by arvinsim on Friday July 19, 2019 @12:25PM (#20479986)
I totally disagree. VueJS and AngularJS feel like PHP/ASP but I never got that feeling from JSX.
Re:Front-end design, React, and a bridge over the great divide by pjmlp on Friday July 19, 2019 @12:41PM (#20480177)
I fail to see how proper component based frameworks, with clean separation of concerns, provide such experience.

JSX is the one mixing echo like statements with proper JavaScript.

Re:Front-end design, React, and a bridge over the great divide by TomMarius on Saturday July 27, 2019 @08:16AM (#20541670)
That is pretty impossible since JSX is just JavaScript, including all of its scope separation. It might be that you're not well versed in using it.
Re:Front-end design, React, and a bridge over the great divide by ngrilly on Saturday July 20, 2019 @09:43AM (#20485707)
JSX let's us define components, usable with the usual HTML syntax. PHP does not. That's why Facebook developed XHP (XML fragments in PHP), which inspired JSX.