HackerTrans
TopNewTrendsCommentsPastAskShowJobs

lassejansen

no profile record

Submissions

Show HN: HyTags – HTML as a Programming Language

hytags.org
69 points·by lassejansen·6 เดือนที่ผ่านมา·33 comments

comments

lassejansen
·6 เดือนที่ผ่านมา·discuss
The main reason for using a stack was reducing verbosity because for short scripts using variables felt unnecessary when the type-prefix of the command already communicates the variable contents. But it could still be a good idea to have a shorter syntax for assigned variables.

Accessing a variables works like this at the moment:

  <selection-set-text $text="varname">
Keeping the dollar syntax, setting the return value to a named variable could look like this:

  <response-get-text $="varname">
lassejansen
·6 เดือนที่ผ่านมา·discuss
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.

  <request-send url="..."> // returns response
  <response-get-text> // looks up response on the stack and returns string
  <selection-set-text> // looks up string on the stack and writes it as text content to the current DOM element.
lassejansen
·6 เดือนที่ผ่านมา·discuss
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, ...).
lassejansen
·6 เดือนที่ผ่านมา·discuss
For most tags you can also put the event handlers as first children inside the element, but self-closing tags like <input> don't support that. I'm now putting the event handlers always outside (as next siblings) for consistency.
lassejansen
·6 เดือนที่ผ่านมา·discuss
Exactly, code is data ;)
lassejansen
·6 เดือนที่ผ่านมา·discuss
It's only frontend logic. There is a small runtime that is implemented in Javascript interprets html tags. Backend logic needs to be implemented on the server.
lassejansen
·6 เดือนที่ผ่านมา·discuss
Thanks dang!
lassejansen
·6 เดือนที่ผ่านมา·discuss
The main reason for using tags was for me that they can be generated from a host language and stay readable, even for longer scripts. I'm using Swifts result builders for my projects, which enables autocompletion and partial type safety.
lassejansen
·6 เดือนที่ผ่านมา·discuss
I did a Show HN for the language "hyTags" yesterday, too. It's a language embedded in HTML, using tags as syntax. It quickly dropped of the new page:

https://news.ycombinator.com/item?id=46599403

Could you add that too to showlang?
lassejansen
·ปีที่แล้ว·discuss
Or, phrased differently, if n has an upper limit, the algorithm is O(1).