tomhallett's comments

tomhallett | 2 years ago | on: SQLPage – Building a full web application with nothing but SQL queries [video]

When I look at the Tiny Twitter example and see the code below, I'm curious if there is a more "SQL" way to implement it.

``` select 'checkbox' as component, 'Terms and conditions' as label, true as required; ```

I'm thinking "What would the workflow of a sql-enthusiast be, to build that page".

I think they'd want todo this first:

``` select * from sqlpage.components; ```

which would list the `name` of each component. Which then takes me to:

``` INSERT INTO sqlpage.dom SET name = 'checkbox', label = 'Terms and conditions ', required = TRUE FROM sqlpage.components ```

(or VALUES syntax for INSERT)

This would allow you to re-order your dom, update dom entries, etc. Very similar to jsx, but instead of jsx creating in-memory javascript objects, it's sqlpage's sql creating rows in a postgres table. Then the SQLPage virtualdom gets transformed into actual html.

Just a thought, :)

tomhallett | 2 years ago | on: Show HN: Alpine Ajax – If Htmx and Alpine.js Had a Baby

random idea: an event for "x-sync:missing". the server responds with `<ul x-sync id=notification>`, but the page doesn't have a matching id (and the notifications aren't inside a different target....). if the last part is slow to figure out, people could opt into it with "x-sync x-sync-required".

tomhallett | 2 years ago | on: Show HN: Alpine Ajax – If Htmx and Alpine.js Had a Baby

A few features which look minor but the author got totally right, which IMHO would allow this solution to scale very well with more complex applications.

1) X-Alpine-Target

``` <form method="post" action="/comments" x-target="comments comments_count" ```

generates an ajax request with this header by default:

``` X-Alpine-Target: comments comments_count ```

This is very very cool! In most usecases, one the serverside I can return a full html document and alpine-ajax will only look for #comments and #comments_count in the response. BUT, if I want the serverside to be faster (ie: do less), then the client is able to tell the server which parts of the html it wants via the `X-Alpine-Target` header -- instead of the server having to know which parts need updating via the url alone. It's like graphql for the htmx/hotwire architecture.

2) `ajax:missing`. If the client expects dom ids to be in the response and they aren't there, you can create a sentry error to expose the broken "contract" between the initial page's request and the action's response.

3) x-merge="append"

In hotwire, the html markup is dumb and the turbo-stream response is smart (`turbo-stream action="append"`). But in alpine-ajax, the response is dumb and the html markup is smart (`x-merge="append">`). This difference is subtle, but it allows for the serverside responses (for actions) be more general purpose/discrete components, while the ux which might change from page-to-page or section-to-section is decoupled to that page's/section's container html.

4) x-sync

"Elements with the x-sync attribute are updated whenever the server sends a matching element, even if the element isn't targeted with x-target."

Wow - amazing developer ux for cross cutting concerns like notifications, flash messages, etc. So practical.

5) Creating demos with an alpine-ajax mock server.... wow, an out of the box way to make standalone component test pages.

tomhallett | 2 years ago | on: Show HN: Alpine Ajax – If Htmx and Alpine.js Had a Baby

My first reaction was “why do I need an htmx-like version written in alpine?” when I could just use htmx. BUT… if you assume that you will need something more low level to complement htmx (“htmx + alpine” OR “htmx + hyperscipt”) and if you decide hyperscript is not for you, then it does make sense to a stack where the higher level is built upon the lower level: alpine-ajax + alpine.

Looks very interesting!

Also loved the comparisons, especially with rails/turbo and the downsides of custom elements wrt tables.

tomhallett | 2 years ago | on: Htmx and Web Components: A Perfect Match

This seems like the best option, because it works just as well if the child components are loaded async (Ie: a tab component loading sub tabs on hover, and then the parent tab container needing to subscribe to that)

tomhallett | 2 years ago | on: OpenAI's employees were given two explanations for why Sam Altman was fired

I’m curious: if one of the board members “knows” the only way for OpenAI to be truly successful is for it to be a non-profit and “don’t be evil” (Google’s mantra), that if they set expectations correctly and put caps on the for-profit side, it could be successful. But they didn’t fully appreciate how strong the market forces would be, where all of the focus/attention/press would go to the for-profit side. Sam’s side has such an intrinsic gravity, that’s it’s inevitable that it will break out of its cage.

Note: I’m not making a moral claim one way or the other, and I do agree that most tech companies will grow to a size/power/monopoly that their incentives will deviate from the “common good”. Are there examples of openai’s structure working correctly with other companies?

tomhallett | 2 years ago | on: Monaspace

Could the “jump” problem be improved with a subtle transition (200ms, 1s, etc) from one state to the other?

If the editor “repaints” commit mono on the letter-pair boundary, I could see that being a very jumpy UX — ie: the letter I just typed is moving by a few pixels. But if that repaint happens on the word boundary it might be less noticeable?

In either case, a transition could be helpful for commit mono and/or Monaspace. (But agreed with above comments that Monaspace is more subtle because it spreads the spacing over the entire word, so maybe the transition is not actually percievable or worth it). :)

tomhallett | 2 years ago | on: Build a Lightweight Code Generator with TypeScript and JSON Imports

The way I interpreted it:

* Person A [Marketer who knows html/handlebars] logs into Postmark and makes a new email template.

* Person A tells Person B [node js developer], "Please send the new 'welcome' email template from the app".

* Person B runs the cli script, so the json file now has a template with a key of 'welcome-template-2023-blue'.

* Person B can write/modify any code which calls "sendEmailTemplate" and know exactly what code is valid, wont compile, etc.

They are "generating" the "class/object/type definitions" programmatically - which seems fine to me for the code generation problem they lay out.

Which part is not "a valid case" to you?

Note: the fact that the article is "typescript + json" versus pure "typescript" doesn't seem like a important distinction with respect to it be valid code generation, not sure if others disagree.

Random note: A different way to solve this problem would be with the "cog" python module [1], but that would come with a different set of tradeoffs. :)

[1]: https://nedbatchelder.com/code/cog

tomhallett | 2 years ago | on: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

100% agreed with you. Here's the part where I agree with user "PoignardAzur":

* user "menaerus" goal is have "C/C++/Rust developer [...] expose your product as a browser service", which they can transpile to wasm - cool.

* they will need "a bit of JavaScript you integrate it into the end service" - UI targets the DOM, sounds great.

The questions become:

* how much code will need to be written into each layer (rust wasm, react html ui, bridge between the 2)?

* what level of experience with that tech will you need todo that? ie: writing a react ui which interfaces with a wasm shim is some non-trivial javascript to say the least.

* based on the above: how far has wasm enabled a "c/c++/rust developer" to easily port their application to the web without also being a super strong frontend developer?

I'm trying to draw a contrast between:

A) I have business logic which is not well suited for javascript (image processing on binary data, figma, etc), and I have rust/c++ developers AND javascript frontend developers to build the application

B) I am a rust/c++ developer who wants to target the web with their rust/c++ product, but doesn't want to dive deep into frontend/js/react tech.

In the long term, I am optimistic that scenarios like "B" will be opened up by application (web) frameworks which target wasm via backend technologies and their MVC patterns. But in the short term, the amount of "glue code" to be written is non-trivial.

tomhallett | 2 years ago | on: WasmGC – Run GC languages such as Kotlin, Java in Chrome browser

Yes, but it's important to think about the bridge/shim between your application code (the web assembly module) and the host (the browser). If you have a C++ game which draws to the screen with SDL, then you can use a shim to convert SDL calls into html canvas calls [1]. But if a backend engineer wants to compile their java swing application to web assembly, there is a larger impedance mismatch from Java Swing => react html, then from Java Swing => html canvas.

If your application is built upon a web framework which already has this translation layer, like Blazor, then the amount of harness/shim-glue code you need to write goes down.

1: https://web.dev/articles/drawing-to-canvas-in-emscripten

tomhallett | 2 years ago | on: How to Fetch a Turbo Stream

In this case, are you recommending the serverside validations (is a promo code still active and not expired) run after the call to stripe's confirmPayment, because you have a clientside validation (promo code matches a regex)? If so, that seems problematic because your severside validation could have prevented stripe from ending up in a dirty state. If not, then I'm not following what you are recommending.

tomhallett | 2 years ago | on: Don't use DISTINCT as a "join-fixer"

Any recommended resources (books, courses, etc) which go deeper on sql topics like this? Comparing and contrasting different ways of writing the same query, with respect to performance.

The one book I’ve found and really enjoyed was “SQL Performance Explained”.

tomhallett | 2 years ago | on: Calif. passes strongest right-to-repair bill yet, requiring 7 years of parts

I'm wondering if it was a carve out that was easy to give, doesn't water it down too much and is helpful for other politics:

* Sony produces semi-conductors and movies (Sony Pictures, Columbia, Tristar)

* Microsoft is big in enterprise cloud (ie: government)

* the impact of people being forced to upgrade their phone because they can't fix it, is probably larger than people being forced to upgrade their game system because they can't fix it

Note: I 100% agree with you. I see video games as the same as all other consumer electronics which were included, but I can see if Sony/Microsoft came complaining, it's a good bargaining chip/favor for other initiatives.

tomhallett | 2 years ago | on: My Node.js is a bit Rusty

I think we can all agree that the blog article, while interesting and tells a story about the way the author solved a problem, does not have high enough rigor to serve as a benchmark for "don't do this, do this instead", or "this language is bad at this, and this one is better". Those types of statements would require much more rigor and A vs B comparisons where code A and code B are the same, just in different languages.

BUT, what I am interested in - if I'm using javascript to parse a large file line by line, plucking off specific fields like the example does, what can I try to see if it's more GC-friendly? Obviously the answer is always some flavor of "profile it" and "it depends". If the blog author could have gotten a big boost in performance by adding 10 lines of js code to their loop, that is something all readers of the article could benefit from.

I will play around with it and see what I can learn about the V8 GC. For reference: here is a talk about profiling the ruby gc, which helped me fix a memory leak at work (https://www.youtube.com/watch?v=kZcqyuPeDao).

page 3