Live data from Hacker News

Hyperscript Tagged Markup: JSX alternative using standard tagged templates

github.com

11–20 of 93 posts

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#11
post #3

This is a neat syntax, but it doesn’t seem at all typesafe (typesafety was the main benefit of JSX over the various string templates that came before it).

> typesafety was the main benefit of JSX Do you have a source for that?

What kind of source do you have in mind? The arguments types that are valid will vary based on the content of the template string, and no type system (well a dependently typed language such as Idris could do it) for JS (flow, typescript) supports that.

On the other hand, both TypeScript and Flow support type checking for JSX attributes (and child elements to some extent)

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#12
post #3

This is a neat syntax, but it doesn’t seem at all typesafe (typesafety was the main benefit of JSX over the various string templates that came before it).

> typesafety was the main benefit of JSX Do you have a source for that?

Why would you need an external source for a personal opinion?

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#16
So,I guess mixing presentation and logic is OK now? 'Cos as a PHP programmer I used to get shat on all the time for that and I'd like a chance to, you know, unload on someone else for a change.

NM, I'll just go back to my cave now.

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#18

So,I guess mixing presentation and logic is OK now? 'Cos as a PHP programmer I used to get shat on all the time for that and I'd like a chance to, you know, unload on someone else for a change. NM, I'll just go back to my cave now.

There's presentation logic vs business logic.

Tracking whether a button is disabled or not is presentation logic.

Projecting a snapshot of business state onto a presentation is also presentation logic.

"Old school PHP application" style seldom made a distinction.

Also, you must add indirection (bad) to split things apart, and indirection doesn't necessarily pay its own rent. An example would be putting an ajax api request (a client's business concern) into a component where the exists that triggers it. Collating that logic with the UI is nice until you want to reuse the logic, and it's usually cheap to extract it from a component, so you can often add indirection on an as-needed basis as you scale.

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#19
post #9
post #6

How is this different from lit-html? https://github.com/Polymer/lit-html

HTM is React-compatible, and has all the React semantics: e.g. you can interpolate attributes (with ...${foo} instead of React's ...foo) and tag names (with instead of React's capitalization-dependent ). In other words, HTM is a drop-in replacement for JSX that avoids the need for a compiler by using the corresponding language features. (At the cost of a few extra ${}s.) lit-html and its ilk render directly to the DO…

I wouldn't describe it as a "drop-in replacement". It's very similar in the way that it allows one to use html syntax within javascript, and I appreciate the fact that it doesn't require and extra compilation step. But it does appear to be lacking what I see as the main draw of %eact -- the ability to compose and remix components. (Correct me if I'm wrong?)

Edit: Composability does appear to be a feature. I agree with your description.

Re: Hyperscript Tagged Markup: JSX alternative using standard tagged templates

#20
The nice thing about React, vs others like Vue and Angular, is that we've learned not to write code in strings. You'd think this would be a fundamental law of software engineering, but we keep seeing things like

    v-bind:id="'list-' + id"
or

    
or this.

Writing code, not strings, means you can do everything to it that you can do to code. You can type check code. You can lint it. You can optimize it, compile it, validate it, syntax highlight it, format it with tools like Prettier, tree shake it...

That's why I like JSX, it's Javascript all the way down. Everything is code. It's a very well designed and thought out DSL.

Post reply on HN