Hyperscript
hyperscript.org
hyperscript.org
It is easier to read rather than to write by design and is inspired by HyperTalk, the scripting language for HyperCard. I don’t expect or recommend it to be a general replacement for JavaScript, but it can be nice for light scripting for the web.
As far as features go, besides the xtalk based syntax it has things like CSS literals and relative positional expressions that make scripting the DOM easier:
on click toggle .active on the next <div/>
probably the most interesting feature to most HN is that the runtime automatically resolves promises so script writers don’t have to:https://hyperscript.org/docs/#async
this, coupled with event-based control flow can make for some interesting scripting patterns.
Anyway, not for everyone but it is a passion project of mine and is being used in production. I’m hoping to get it to 1.0 this summer after htmx 2 stabilizes. Happy to answer questions.
I don't think it maps well to macros, it's just an open parser that you can plug new stuff into pretty easily by adding a keyword + some parsing and eval logic to dynamically.
on click
fetch /foo
then put the result into mei don't have strong opinions on that, i've been told by people who work on the browsers that, from a practical perspective, custom non-data attributes are supported and always will be, and the underscore attribute is a tribute to underscore.js, a library I always liked.
i am not ideological about it
But, I don't think another language that tries to abstract the fundamentals is the solution to that. I think this is true for Hyperscript - as much as it is for JSX and Co. JavaScript is the most widely known programming language, has the most extensive knowledge base and the biggest ecosystem. And there's no shortage of frameworks that make using it easier without reinventing the wheel.
I believe using anything else for a serious project severely limits the talent pool from which you can hire, the ecosystem you can draw from and the maintainability of your project in the long run.
Why can't we extend standards-based languages using the built-in custom extensibility they already have?
No one wants to do that.
Has anything improved since?
Some previous discussion from 2021: https://news.ycombinator.com/item?id=26873682
Do we have some htmx flavor ability to fetching raw html string and update elements with it?
Frontends do not need boilerplate, they need a simple, efficient and maintainable way of interacting with data and managing mutations.
There is no need for a light JS replacement to be as verbose as prose. The Venn diagram of engineers trying Hyperscript out on their side projects and people unfamiliar with code syntax are two distinct circles.
If you want to put logic in HTML attributes, it needs to be concise and expressive, not resembling English prose. Even APL would be a better choice.
I once had a Venn diagram to display the set of people who are fluent in APL-like languages but it was so small I needed a microscope to see it. Now I've no idea where it might be, I'm afraid I accidentally brushed it from the table along with some breadcrumbs
I see a visual language Node-RED with tunable parameters in nodes as the way but have kept up with this project a little... no reason user scripts need to be one or the other.
I guess developers will be valuable in implementing and supporting users in any case, I see these tools as reducing support and maintenance for doing variations from the day to day business use more than replacing the dev team.
on click toggle .active on the next <div/>
Certainly not for everyone but it is being used in production in multiple applications.