RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite
github.com
github.com
I'll offer one here... using HTMX usually means you're going to be writing HTML templates, and HTML templating languages don't have much IDE support. I really miss goto-definition etc. when I'm writing Jinja templates.
That being said, I've personally found Rust/HTMX to be a magnificent combo. I personally find writing backend endpoints in Rust to be no more cumbersome than any other language (after becoming comfortable with Rust)... and there's massive gains from the incredible tooling and type system.
I wonder if you've considered using Askama for your templates? It has a Axum integration that cleans up some of the boilerplate around template rendering. There's also an open PR for block fragments [1], which will make componentization of HTML fragments much easier, as discussed in this essay on the HTMX site [2].
We need more projects like this to demonstrate how useful, highly-interactive apps are made with HTMX. I'd encourage skeptics to try the same before writing it off.
[1] https://github.com/djc/askama/pull/824 [2] https://htmx.org/essays/template-fragments/
However JSX has amazing IDE support, but you need to use JS/TS with it. This is where I think the ergonomics of JSX defined Htmx endpoint rendering has been a very natural DX transition moving away from SPAs. Now with CSS View Transitions and htmx element replacements, the user experience is largely just as seamless as developing a spa app.
So it's true, if you're willing to use a DSL embedded in your server language (like JSX), then you'll have the full language tooling available to you. And this probably isn't giving up much over language-specific templates.
A JSX-equivalent for the Rust server-side rendering world would probably be maud [1] or leptos [2].
In reality, it contributes nothing to gpt.
I'm still unconvinced that Rust is a good idea for general web servers due to (overly) aggressive compiler checks and chaotic documentation related to web server concerns (many Rust web related libs cannot work together or not easily).
Today I'm mostly just using Hono+htmx+view transitions. Astro is a similar stack, but with more batteries included (and some additional complexity).
Also, it’d be nice if one could try the demo without creating an account. Otherwise I’m just judging by your screenshots.
warning: `rustgpt` (bin "rustgpt") generated 15 warnings error: could not compile `rustgpt` (bin "rustgpt") due to 19 previous errors; 15 warnings emitted
It was the same for Go when i was using Go. Why is this always debated?
Maybe you should search around for solid projects and look into them in order to gain appreciation the language.
Or watch a couple of videos from Jon Gjengset, like his recent "Implementing (part of) a BitTorrent client in Rust" [0] while keeping in mind that the code he's writing is memory safe, which would probably not be the case with C at the same expertise level and speed of development. And considering that it is a BitTorrent client, one would definitely want it to be memory safe.
If you're coming from C/C++/C# you get very good memory guarantees, a standard library that is very well fleshed out, a well supported package manager and a fairly robust (though a bit immature still) ecosystem.
If you're coming from Java or Golang, you have the benefit that now your code can be consumed by other languages. You also get the memory guarantees, better error handling ergonomics, and in the case of Java the ecosystem is much higher quality and safer (at least in my extensive experience).
From Java specifically (and any of its derived languages), you loose all the operational and memory problems that come with just starting the JVM.
If you're coming from Python, Ruby, JavaScript the biggest benefit is probably performance but you get all the benefits that Java and Golang do as these are also dead end languages.
There is a lot of quality of life, safety, security, and performance benefits but what matters the most to YOU is going to largely depend on where you're coming from, what you want to build in it, and what your priorities are. It legitimately isn't for everyone, but its a VERY good choice as a default language.
> Why not Bun?
On a perfectly fine project that was using Deno instead of Bun. You can't really have it both ways.
e.g.
hx-delete="/chat/{{ chat.id }}" hx-target="#chat-{{ chat.id }}" hx-swap="outerHTML"
- send a DELETE request to /chat/chat.id
- the response is going to swap the content of the #chat-chat.id element
How could I implement an error flash message in case the delete fails in this case?
The server can include a couple response headers to override the placement of the message to not affect the existing page state
https://htmx.org/docs/#response-headers
This allows the error to either be added inline in the UI somewhere or (my preference) displayed as a toast by appending to the end of the <body>