3 ms·
Show HN: HJX – An AI-Native Web Language Unifying HTML, CSS and JavaScript
Show HN: HJX – A Unified Web Language Designed for AI-Native Code Generation
Hi HN,
I’ve been exploring a language design where structure, style, and logic live in one authoring unit — to reduce token fragmentation when AI models generate frontend code.
HJX is a compiled UI language that unifies *structure*, *style*, and logic into a single `.hjx` file.
It compiles to clean, dependency-free HTML + CSS + JavaScript — no virtual DOM, no runtime overhead, no framework lock-in. :contentReference[oaicite:1]{index=1}
Here’s a real example from the README:
```hjx
component Counter
state:
count = 0
layout:
view#root.card:
text.title: "Count: {{count}}"
button.primary (on click -> inc): "Increase"
style:
.card { padding: 16px; border: 1px solid #ddd; border-radius: 12px; }
.primary { padding: 10px 14px; border-radius: 10px; cursor: pointer; }
handlers:
inc:
set count = count + 1
```
Happy to answer questions about the hjx and open for pr
-Loaii abdalslam
- loayabdalslam 8mo agoThanks for checking out HJX! A bit of backstory: I started building this after noticing how much context switching LLMs do when generating UIs across HTML, CSS, and JS. Instead of three syntactic domains, HJX tries to unify structure, style, and interactivity into a single block-based syntax that still compiles down to plain HTML/CSS/JS. Right now it’s an early prototype with a basic compiler design. I’d love to hear: - Does this unified syntax reduce token/context fragmentation for AI models? - Any suggestions on grammar design or compiler targets? - Use cases you’d want to see supported? Happy to iterate based on feedback.
- verdverm 8mo agoWhy do I want a bespoke language generated by an Ai, as compared to JSX + tailwind which I see as basically the same "html/css/js" without context switching (all in the same file), and something the Ai have seen significant amounts of during training? If I use something bespoke, then I have to do in-context learning, so am I really saving tokens in the long-run? (before we even get to more frequent failures / hallucinations that come with the bespoke)
- loayabdalslam 8mo agoActually, we're not like JSX; we offer a capsule solution. I can't show you my complete vision for the project right now, but if we could create a code generator using that language, it would be about 1000 times faster than normal because everything it generates would be in one place, in one way, and with one method, without retraining—just one agents.md file explaining the language.
- stephenr 8mo agoWhy am I not surprised that the solution to one bad idea, is another bad idea. There is already a way to put html, js and styling in a single file, and it was all the rage around 1997-2000, the last time humans were routinely using shitty software to generate code for them. It took quite few years for people to learn those mistake the first time.
- loayabdalslam 8mo agoActually, the idea isn't bad; it's just that we haven't seen the problem yet. The way AI thinks needs to be simplified and not consume so many tokens. It's not just about AI creating a language; I'm working to fundamentally change the way languages on the web are used.