4 ms·
+1. It's all strings (of source code) in the end. It's just a matter of how well the tools support those strings. There exists a medium-sized ecosystem of tool
by domenicd 8y ago
+1. It's all strings (of source code) in the end. It's just a matter of how well the tools support those strings.
There exists a medium-sized ecosystem of tools which supports static checks on strings inside angle brackets, a la JSX. There is a smaller-but-growing ecosystem of tools that supports static checks on strings inside backticks, a la HTM/lit-html/etc. There's no fundamental difference here.
- dmitriid 8y agoThe fundamental difference is what you have in the end. With JSX you have function calls (JSX is a very thin DSL after all). With tagged literals you end up with runtime string parsing and concatenation.
- rickycook 8y agoand i think this is the point; runtime vs compile time! similar reasons that people love the popular new type systems... if it compiles, it probably works or you get an error rather than pushing that later and possibly not catching it
- magicalist 8y ago> The fundamental difference is what you have in the end. With JSX you have function calls Check out the output of the Babel plugin mentioned in the readme > // input: > html`<div id="foo">hello ${you}</div>` > // output: > React.createElement("div", { id: "foo" }, "hello ", you) options https://www.npmjs.com/package/babel-plugin-htm https://www.npmjs.com/package/babel-plugin-htm
- dmitriid 8y agoIt's (marginally) better than having it at runtime. Poor man's macros. Much like JSX in a sense, though JSX is a much thinner abstraction IMO.