3 ms·
Er...why does this suck? What do you replace it with?
by Sacho 8y ago
Er...why does this suck? What do you replace it with?
- lmm 8y agoIt sucks because you can't even parse it, you can't understand what's going on without mentally switching back and forth between markup and programming language even if the two are in the same file. You replace it with a framework that lets you treat HTML fragments as values in your programming language and write plain old code that follows the normal rules of the language, that can be refactored following the normal rules.
- dmitriid 8y agoHmm... JSX isn't HTML. I thought we established that. Moreover, JSX components are plain old Javascript functions and classes. You write plain old code that follows normal rules if the language when you deal with them. JSX DSL is there for convenience because it's, well, extremely convenient. There are feeble attempts elsewhere to equate JSX with writing HTML inside PHP tags which fall apart the moment you give JSX more than a give-second cursory glance.
- lmm 8y agoI wasn't talking about JSX one way or the other - just trying to explain what the issue with PHP was and how the industry moved away from it.
- dmitriid 8y agoYes. But... JSX is not HTML. And no, the issues PHP had with embedding HTML do not apply to JSX. JSX is a paper-thin DSL on top of Javascript. JSX components are regular Javascript functions and classes. You work with them the same way you work with any function it class in JS. Unlike PHP where it was actual HTML interspersed with PHP code.
- kabes 8y agoI get that JSX is a DSL that ends up being javascript. But there are a lot of arguments why we don't write HTML directly between the PHP which still apply to JSX, even though it's not HTML. For me as a programmer it doesn't matter what happens under the hood. Whether I type `return (<button>foo</button)` in react or echo '<button>foo</button>' in php, it's the same thing from my point of view as an application builder.
- lmm 8y ago> there are a lot of arguments why we don't write HTML directly between the PHP which still apply to JSX, even though it's not HTML. Such as? This is the point in dispute, so you need to actually make specific arguments if you think they apply.