Live data from Hacker News

How I use HTMX with Go

alexedwards.net

61–70 of 121 posts

Re: How I use HTMX with Go

#61
post #4

Love Go + HTMX. I pair it with a-h/templ for a bit more type safety on the template, components and partials. I just shared my whole toolkit too [1], I call it the "GUS stack" -- Go, Unix, SQLite. Inspired heavily by the exe.dev "GUTS" stack [2] but with HTMX instead of Typescript. Some other Go components in the kit... - cockroachdb/errors for errors with stack traces - templ for type-safe HTML templates (with htmx…

Lately I'm really liking jet[1] for typesafe SQL. It requires a live DB to generate the code, but I see that as a positive as well, since you are forced to apply migrations before writing code. [1] https://github.com/go-jet/jet

Huge fan of jet. It lets you just write SQL, but in your Go. I basically can’t imagine using anything else now.

Why is that better than writing plain SQL like in sqlc? My main reason was being able to dynamically construct queries and reuse different bits. Plain SQL statements simply don’t compose at all, and I don’t recall sqlc giving any solution to help with this.

Re: How I use HTMX with Go

#62
post #55

Earlier quoted context omitted.

I'm bit sad that hyperscript[1] doesn't get the love it deserves when discussing HTMX. Hyperscript fits perfectly in the Go + HTMX stack to do DOM manipulation without having to make a server round trip or having to write a separate JS function. I get that not many are fan of such declarative programming, but when there's already HTML file we're working with; Hyperscript feels just like an extension of it. I have bee…

There's security consequences to allowing inline JS, which hyperscript requires.

How so? Final validation always goes in the server side.

Re: How I use HTMX with Go

#63

If you’re using htmx, I highly recommend an HTML generation technique in your backend that lets you easily componentize in the same way as you can with React. Eg, extracting common pieces of HTML markup into functions much like React components. The reason is that htmx requires a certain amount of flexibility in the HTML generated by the backend. Eg, you need to be able to generate a certain piece of HTML markup and…

Agreed, but uhtml-ssr looks a bit dated. If you want a html tagged template literal lib with no dependencies, see for example:

implementation: https://github.com/mastrojs/mastro/blob/main/src/core/html.t...

docs: https://mastrojs.github.io/docs/html-components/

Re: How I use HTMX with Go

#64

HTMX is great for a lot of things, but if you're working in a team, and your colleagues are not on board, it's tough. Lots of "this is not a serious technology" kind of arguments. All kinds of bugs simply initially blamed on the choice of using HTMX. Even if proven wrong afterwards, the damage is already done. And this was in the most excellent team I have worked in so far. I'm happy that I got to experience this and…

[dead]

Re: How I use HTMX with Go

#66
post #27

Earlier quoted context omitted.

they never said "couldn't". they said "feels like the complexity"

Ok, what’s an example of the complexity growing at 2:1 rate with htmx but not with Mantine?

Basically any data grid that implements multiple AND/OR filters at column level, sorting, reordering, infinite scrolling, virtualization for handling large amounts of data, etc. Also handling basic pending / error / retry states (things that I take for granted with React Query).

Re: How I use HTMX with Go

#67

HTMX is great for a lot of things, but if you're working in a team, and your colleagues are not on board, it's tough. Lots of "this is not a serious technology" kind of arguments. All kinds of bugs simply initially blamed on the choice of using HTMX. Even if proven wrong afterwards, the damage is already done. And this was in the most excellent team I have worked in so far. I'm happy that I got to experience this and…

As much as I really like htmx -- this is a sad truth!

I tried to pitch htmx to my team last year and found an opportunity to create a simple webapp. One of the devs really struggled with htmx after years of muscle memory returning json and rendering in JS/JQuery. It was a lot of "I now have to do this.. how do I solve this problem?"

I think he would have struggled with any different approach whether we changed to angular, react, etc. htmx didn't really stand a chance.

The other dev, on the other hand, didn't even bother to try it.

All I heard from the team was Blazor this, blazor that.

Personally I think it's a shame. We are a small team and would be good to avoid javascript 95% of the time. We could just generate server side code/html which, imo, would create organised code base. Easy to test as well.

Any personal web projects I still use htmx and reached a decent flow with it. Completely simplifies web dev, imo.

Re: How I use HTMX with Go

#68

HTMX is great for a lot of things, but if you're working in a team, and your colleagues are not on board, it's tough. Lots of "this is not a serious technology" kind of arguments. All kinds of bugs simply initially blamed on the choice of using HTMX. Even if proven wrong afterwards, the damage is already done. And this was in the most excellent team I have worked in so far. I'm happy that I got to experience this and…

Exactly the same thing happen to me: https://www.reddit.com/r/htmx/s/DuXyGgsCWK

I'm in an advisor position, and I tried very hard to mentor the team, explaining that learning this technology deepens your understanding of the browser. Whereas React etc isolates you from the actual environment you're working in - the browser.

On html/template, I like the security by default, and obviously it's built-in. But the dynamicness leaves too many open-ended questions unanswered. Templ is great, but the ergonomics leaves many things to be desired. After writing a few large production applications in it. I decided to create gsx: https://github.com/gsxhq/gsx

Re: How I use HTMX with Go

#70
post #57

Earlier quoted context omitted.

I'm unfamiliar with these stacks but including "U" / Unix seems odd. I suspect these run completely fine on Linux, Windows or macOS. Its almost like including an "E" in your stack for electricity.

Well, the good old LAMP stack (Linux-Apache-MySQL-PHP - this was the first of these acronyms as far as I'm aware of) included L for Linux so it would make a nicer acronym. Some people changed it to WAMP when running under Windows. But HWGS doesn't roll off the tongue nicely. Maybe HAGS (with "Apple" standing in for MacOS) would work?

Or HOGS? HTMX-OS-Go-Sqlite. While having "OS" in there is kind of redundant, it does make for a nice and general acronym.
Post reply on HN