Live data from Hacker News

JSX is no longer my friend

medium.com

41–50 of 144 posts

Re: JSX is no longer my friend

#41
I was nodding and agreeing right up until he got to the part where he was talking about how he's using Hyperscript as a replacement. Hyperscript's just the same problematic design with a different syntax.

Mixing HTML and server side code may let you do toy projects quickly, but in the real world it's a great recipe for building an unmaintainable, undifferentiated, monolithic mess.

Re: JSX is no longer my friend

#42
post #31
post #12

Finally, somebody said it. I thought we abandoned that garbage when we left PHP, and now all of a sudden everybody wants to start mixing markup and code again?

Exactly this. Can someone explain to me what do people see in JSX way of creating components? What happened to good ol' code vs template separation and what's now wrong with having two separate files - .html (or jade, or whatever) and .js?

What does code/template separation actually achieve? Ignoring JSX for a moment, why are templates a good thing? Are you actually simplifying something by using {{#each}} instead of .map()? Is {{#if}} really better than if()? Seems to me like templates don't actually decouple code.

Re: JSX is no longer my friend

#43
I'm wondering what the advantages of JSX are now in a world with ES6 template strings?

This seems plenty easy to read and write and has the benefit that it's pure JS and doesn't need to be compiled during development:

  const listItem = item => `${item.name}`
  const listComponent = items => `${items.map(listItem).join("")}`

Re: JSX is no longer my friend

#44
post #28

After many Medium posts of uninformed, not very insightful complaints about react and the state of JavaScript I am becoming inclined to just avoid Medium posts about JavaScript in general. Medium has become the analog to Tumblr posts for opinionated engineers to whine about things that don't really impact development in ways that matter. Really all this developer had to do was talk about Hyperscript in a positive way…

Seriously. If you like it, use it. If you don't like it, don't use it. If you work with a team, take a vote.

This post spends quite a bit talking about beginners who are learning Javascript, React, and JSX all at once. Of course they aren't going to get it right immediately, if they didn't get tripped up on JSX they'd get tripped up on something else. "Beginners don't get it" might be the weakest argument I've heard so far.

Re: JSX is no longer my friend

#45
post #28

After many Medium posts of uninformed, not very insightful complaints about react and the state of JavaScript I am becoming inclined to just avoid Medium posts about JavaScript in general. Medium has become the analog to Tumblr posts for opinionated engineers to whine about things that don't really impact development in ways that matter. Really all this developer had to do was talk about Hyperscript in a positive way…

> Putting HTML directly into my JavaScript is awesome and I never want to go back to separate template pages ever again.

Note that the author isn't suggesting a return to separate template pages. He is suggesting a system for creating React elements that uses simple functions and JavaScript syntax rather than the custom syntax of JSX.

Re: JSX is no longer my friend

#47
post #43

I'm wondering what the advantages of JSX are now in a world with ES6 template strings? This seems plenty easy to read and write and has the benefit that it's pure JS and doesn't need to be compiled during development: const listItem = item => ` ${item.name} ` const listComponent = items => ` ${items.map(listItem).join("")} `

It was discussed a long time ago. Some googling found this very old link

http://facebook.github.io/jsx/#why-not-template-literals

Re: JSX is no longer my friend

#48
My brain parses JSX way better than Hyperscript, so I will stick with it and suffer the extra keystrokes.

And the context switch has not proved to be a problem for me, but I'm sympathetic to the argument.

Re: JSX is no longer my friend

#49
post #28

After many Medium posts of uninformed, not very insightful complaints about react and the state of JavaScript I am becoming inclined to just avoid Medium posts about JavaScript in general. Medium has become the analog to Tumblr posts for opinionated engineers to whine about things that don't really impact development in ways that matter. Really all this developer had to do was talk about Hyperscript in a positive way…

I think his points about new developers having to learn JS, React, and JSX all at the same time and then context switch between them in ways that aren't entirely clear was pretty spot on. I don't know how you draw that comparison without mentioning the shortcomings of JSX. Also with Hyperscript you're still building your markup directly in your Javascript, just using JS for it instead of JSX, not templates. Not sure if that's what you meant with your "separate template pages" statement.

Re: JSX is no longer my friend

#50
post #43

I'm wondering what the advantages of JSX are now in a world with ES6 template strings? This seems plenty easy to read and write and has the benefit that it's pure JS and doesn't need to be compiled during development: const listItem = item => ` ${item.name} ` const listComponent = items => ` ${items.map(listItem).join("")} `

The difference is in when the code blows up if there's a typo. With JSX/hyperscript, it blows up with a syntax error at parse time; with strings, it blows up at runtime.
Post reply on HN