logoalt Hacker News

Show HN: HyTags – HTML as a Programming Language

51 pointsby lassejansenyesterday at 10:57 AM24 commentsview on HN

This is hyTags, a programming language embedded in HTML for building interactive web UIs.

It started as a way to write full-stack web apps in Swift without a separate frontend, but grew into a small language with control flow, functions, and async handling via HTML tags. The result is backend language-agnostic and can be generated from any server that can produce HTML via templates or DSLs.


Comments

velcrovantoday at 6:22 PM

HTML (and XMLish syntax in general) is LISP syntax (not semantics) in disguise. A tag can be viewed as function application, with the attributes as named arguments and the elements as variadic arguments.

The example from the link's main page is equivalent to:

    (button "Say something")
    (on_click
      (selection-insert-after
        (div "Hello, World ")))
[apparently HN strips all emoji but you get the idea]
show 3 replies
radarsat1today at 7:45 PM

Reminds me of ColdFusion. Don't recall having a great time using it, though I was very young at the time so maybe my memory is distorted on this.

show 1 reply
scatbottoday at 5:24 PM

This seems similar to _hyperscript, except it uses custom tags instead of the "_" attribute. I'm not sure which approach is better, but personally, I prefer keeping the same document structure and varying behavior through attributes. Easier to rewrite on the fly. Custom tags can be clearer in some cases, but attributes tend to work better with existing HTML and tooling.

show 1 reply
bdcravenstoday at 7:15 PM

I remember when one of the primary criticisms of ColdFusion was programming logic in the form of tags.

akhil08agrawaltoday at 6:14 PM

Interesting idea. As a product person I'm immediately thinking about security. how does this handle auth, data validation, etc when backend logic is embedded in HTML?

But that said, this could unlock some interesting use cases where security isn't the primary concern. Like few internal tools, prototypes, small side projects where the tradeoff might be worth it.

show 1 reply
css_apologisttoday at 6:30 PM

first let me say i applaud you for experimenting and doing something unconventional

- thoughts as i was reading this -

ok, so we're programming via an AST vs syntax

I think this is interesting, however there's notable downsides - verbosity, dom bloat & debugging

A potential upside to this is very odd but interesting meta programming capabilities, since the code should be able to inspect & modify itself fairly easily by inspecting the dom

I am inclined to distrust the claim that this reduces complexity as most of the actions are mutation heavy directly to the dom, and the stack based programming is something i struggle to practical examples where it is a significant improvement to mainstream strategies

show 1 reply
antomaltoday at 6:35 PM

This looks very interesting! It reminds me of the approach taken by HTMX or Alpine.js, but with deeper control flow logic. In your opinion, what is the main advantage of hyTags over HTMX for developers managing complex UI states?

show 1 reply
givantoday at 7:38 PM

HTML can be so powerful when used as DOM instead of plain string as is sadly used in most html templating engines on the backend, one example of DOM template engine built by myself https://github.com/givanz/vtpl

cataparttoday at 5:29 PM

Neat! Looks like a pretty straightforward way to develop.

I'm a little too enamored with web components to give it more consideration/testing, but it looks like it could be great for blue sky/green field projects.