Live data from Hacker News

Show HN: HyTags – HTML as a Programming Language

hytags.org

11–20 of 34 posts

Re: Show HN: HyTags – HTML as a Programming Language

#11
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

Re: Show HN: HyTags – HTML as a Programming Language

#13

Earlier quoted context omitted.

Exactly, code is data ;)

Not sure how homoiconicity is related to this at all. Macros don't seem involved. But I do think s-expressions are an improvement over HTML in certain scenarios. That said (talking to OP now), why is the control handler outside the button? In actual HTML, we have [button onclick="codeToBeEvaled()"] In this thing, you have [button][onclick [sub-expressions]] With s-expressions, at least you have some semblance of func…

For most tags you can also put the event handlers as first children inside the element, but self-closing tags like don't support that. I'm now putting the event handlers always outside (as next siblings) for consistency.

Re: Show HN: HyTags – HTML as a Programming Language

#14
post #12

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?

I think the approach of HTMX is that UI state is primarily managed by delegating DOM updates to the server and then modifying the DOM with the response.

With hyTags one can do a lot of things without server calls and without resorting to javascript (e.g. inserting and deleting new rows, showing a loading indicator, validating input, animations, ...).

Re: Show HN: HyTags – HTML as a Programming Language

#15

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…

DOM bloat can certainly become a problem when adding lots of code in e.g. table rows. I added functions mainly to be able to move common code into a central place to minimize that problem.

You certainly must get used to the stack based approach. I tried to make it more approachable by making stack lookups type based (automatic search for value with matching type) and by using type-prefixed commands, e.g.

   // returns response
   // looks up response on the stack and returns string
   // looks up string on the stack and writes it as text content to the current DOM element.

Re: Show HN: HyTags – HTML as a Programming Language

#16

Earlier quoted context omitted.

Exactly, code is data ;)

Not sure how homoiconicity is related to this at all. Macros don't seem involved. But I do think s-expressions are an improvement over HTML in certain scenarios. That said (talking to OP now), why is the control handler outside the button? In actual HTML, we have [button onclick="codeToBeEvaled()"] In this thing, you have [button][onclick [sub-expressions]] With s-expressions, at least you have some semblance of func…

>But I do think s-expressions are an improvement over HTML in certain scenarios.

I agree. S expressions are a data interchange format. HTML is a markup language. They solve different problems.

S expressions define nested lists of atoms. HTML describes semantic hypertext documents defined by a document tree made of element nodes as subtrees, attribute nodes as subtree metadata, and text nodes. In some scenarios a uniform data structure like s expressions is nicer to work with.

To be honest it boggles my mind that XML was ever used as a universal data format.

Re: Show HN: HyTags – HTML as a Programming Language

#17

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]

I'm not sure I see your point. Yes, you can describe the same meaning/structure with S-expressions and HTML/XML syntax, but that's the complete opposite of having the same syntax, in fact syntax is the difference!
Post reply on HN