3 ms·
Why is JSX still a thing?
- acemarke 3y agoSome possible reasons: - React already used JSX, so no reason to suddenly change - JSX can be type-checked by TS - Template literals aren't going to contain flow control the way JSX can
- MBCook 3y agoHow about people like it? I do. At least more than the idea of switching to something else. Nothing about it annoys me enough that I would like to switch. I’m quite content.
- jfengel 3y ago"People like it" is an underrated consideration. All programming languages are, at core, equivalent. The situation with frameworks is similar. As a designer you're looking for an abstraction that helps people feel like they understand what's going on. They can express themselves concisely and clearly. It's a human problem, not a technical problem, and your metric largely comes down to "people like it".
- jfengel 3y agoBut JSX? Once template literals showed up, I have no idea why JSX didn’t die out immediately. Generating code with template literals is how you get SQL injection attacks. You can't tell until runtime whether the code you're writing is valid or not. When you write JSX you get support from your IDE: managing close tags, clearing up indentation, autosuggest for tag attributes, etc. I get that it's annoyingly heavyweight to have to put a transpiler in between your code and the execution environment. But the larger your project gets, the more likely you'll want something (typescript, packaging, etc.) that shifts some of the burden onto the compiler. Sure, you can do without, just like you can write code without an IDE. But I think I'm more productive.