←back to thread

69 points jdkoeck | 1 comments | | HN request time: 0.286s | source
Show context
bevr1337 ◴[] No.44437257[source]
> Nested function calls (like React's createElement() or Hyperscript's h()) or object-based builder-style APIs just don't look enough like HTML.

What is "enough" here? It is good enough for the unified community. I know npmtrends.com isn't the best metric, but unified is popular. Unified has made it trivial to move between HTML, MDX, MD, JSX and even combinations of the above. I'm learning it's an opinion, but hyperscript and hast are HTML enough being that they're models of HTML

Hooking into a tagged template is a challenge. Functions will receive a list of unparsed html strings and already evaluated expressions to zipper up themselves before forwarding to the downstream template API.

https://stackoverflow.com/questions/39971088/evaluating-temp...

Unlike an expression or tag, a developer can hack on any AST or hyper script provided by a library. Im not sure proxies or reflection are useful working with string primitive and they're unergonomic.

This was something I mentioned on the other post so I appreciate seeing it called out clearly in the reply. (Not to assume I inspired the mention.) Thank you for sharing.

replies(1): >>44437544 #
jfagnani ◴[] No.44437544[source]
Author here: Those don't look like HTML enough because they're not markup. Every single one of the top frameworks uses markup with interpolations as their basic template format: React, Vue, Angular, Preact, Lit, Svelte, Solid, Quik, Stencil, Marko, Polymer, FAST, and on and on.

Frameworks and rendering libraries that don't have a markup-based template syntax are just very rare.

And I think for understandable reasons: Markup-based templates look like the output, and web developers know HTML, so the templates are easier to read and write.

That StackOverflow question seems unrelated because it's asking about untagged template literals. With tagged template literals, depending on the return type, you can absolutely get to the underlying values.

replies(1): >>44437684 #
1. bevr1337 ◴[] No.44437684[source]
> That StackOverflow question seems unrelated because it's asking about untagged template literals.

The first answer reinvents tagged templates and the second suggests them. I thought it was a good example to show the complexity of hacking in this approach. I'll add more context in the future.

I'm agreed that the average developer would hate working with an an AST -- JSX covers 99.9% use-case and React codebases are full of functional programming escape hatches -- but it is the foundation. An HAST is an interoperable, extendable representation we can move between any framework or tooling.

I'm likely projecting too much on the proposal. Templating is the top priority but it's the ancillary bits you mention that excite me most.

> Markup-based templates look like the output

I made the mistake of drinking functional programming laced koolaid, so in my mind they really do translate well, but I respect that you have a broader perspective.

Thanks for taking the time to reply. I'm a smidge honored that you'd even review my feedback!