loading...

Discussion on: Svelte for Sites, React for Apps

Collapse
codechips profile image
Ilia Mikhailov

Performance and size are two factors that often can be optimized, but what about DX? Ever had to add forms to your React app? Spent time deciding on which forms library is best, finally went with Formik, and then spent half a day trying to find the optimal integration way for just your app. Ever got lost in hook hell? Are you sure you understand how useEffect works and where you should use it? My point is, React is overly-complicated and React fatigue is real.

I think that you should use technology/framework that makes you most productive while reducing your cognitive load at the same time. Newbies often jump on the React bandwagon because it comes from a big company and "everyone is using it".

I don't blame them. After all, it's where the money and jobs are. But do I feel sorry for them, because React is not easy to learn and IMO not a good first introduction to web development.

Also, JSX should be a low assembly language instead of something you write your apps in. Change my mind.

Collapse
seanmclem profile image
Seanmclem

Everybody is different.

Collapse
swyx profile image
Collapse
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Also, JSX should be a low assembly language instead of something you write your apps in. Change my mind.

Not sure I know what this means. JSX is just another way to write HTML, except it's in JavaScript and gets compiled to HTML. I'm not sure how it's even comparable to assembly...

Collapse
codechips profile image
Ilia Mikhailov

So is it JS or HTML? Just kidding, of course. To me personally JSX always felt low level, something that is better suited to be generated by a machine from some higher templating language and then compiled to HTML. svelte-check tool does this to validate Svelte's templates for example. But the good thing is that we all have freedom of choice. Use whatever makes your heart beat.

Collapse
peerreynders profile image
peerreynders

JSX is just another way to write HTML, except it's in JavaScript and gets compiled to HTML.

It compiles down to JavaScript React.createElement calls - not HTML.

JSX sees itself as an XML-like syntax extension to ECMAScript (i.e. not HTML).

So the common complaint is "what is this XML doing in my JavaScript code".

"I still maintain that JSX is pretty horrible."

Thread Thread
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Yup, you're right, JSX compiles down to React.createElement calls, which create elements (JSON blobs really) that describe UIs. But at the end of the day, these just translate into native DOM render calls. "Compile" was a poor choice of wording on my part :)

Having worked with React for about two years now, I honestly don't see the problem with JSX. It's an excellent, declarative syntax for creating UIs.

Thread Thread
peerreynders profile image
peerreynders

(JSON blobs really)

Naahh... React Elements ... which if I understand correctly are more generally vnodes.

"Compile" was a poor choice of wording on my part :)

It was the "HTML" that prompted me - "compile" is often used where "transpile" is appropriate - the issue is when people see JSX as markup rather than function calls; HTML only gets generated for SSR, not for client side rendering.

I honestly don't see the problem with JSX. It's an excellent, declarative syntax for creating UIs.

JSX as part of a sequence of JavaScript statements can be quite imperative; e.g. Marko's components are more declarative - the imperative behaviour of the component is clearly separated from its rendered representation; no "context switching" while reading JavaScript code.

But clearly there are people on both sides of the fence.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt

If you are talking about compiled Javascript (e.g. es5, minified), I think it is always Hyperscript, not JSX.

Collapse
jfbrennan profile image
Jordan Brennan

I wouldn't want to change your mind - you have freed yourself my friend! Welcome to the other side :)

Collapse
codechips profile image
Ilia Mikhailov

Not sure what side you are referring to, but thanks. I took the path of least resistance πŸ€·β€β™‚οΈ

Thread Thread
jfbrennan profile image
Jordan Brennan

Everyone in front-end has to go through React at some point, but not everyone makes it through to the other side, i.e. the latter end of the React experience where you've realized it's a total pain and there's many smaller, easier, more enjoyable options out there.

Thread Thread
codechips profile image
Ilia Mikhailov

Totally agree. However, it requires courage and an open mind. Also helps if you've been in the game for some time too. Herd mentality and FOMO are strong. You are running in the opposite direction than everyone else and that can be scary.