-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop an approach for frontend/UI #130
Comments
(Came here from your Reddit post.) "Productivity" is probably the most subjective possible metric here. The range of answers you've already either proposed gotten on Reddit is so wide as to cover the full spectrum of things that could possibly run in a web browser, from slint (doesn't even use HTML/DOM but renders into a canvas) to Hotwire (doesn't do any frontend but diffs new HTML from the server). Maybe this reflects the fact that people are the most productive in the tool with which they're most familiar. That said, a few technical points:
Given all that, personally, I'd very strongly recommend you choose a Rust HTML templating approach that you like, and make it obvious to people how to return HTML in a blessed way. (I don't see this at the moment in examples or docs but will admit I haven't read them thoroughly.) You could build "and here's how to have a React frontend that only supports half of React's features and adds a bunch of additional complexity and build tooling" but if someone wants a full-featured framework using React they're just going to go for NextJS anyway... |
Thanks @gbj this is what I'm taking from your thinking:
|
Here are a few thoughts in addition to @gbj's great comment
It's worth mentioning that I am an admirer of Leptos and think it's excellent, great work @gbj. If I were using Loco myself for a personal / side project I would choose Leptos to continue working in Rust, reduce my language switching, and share code and types. In SaaS or general business environment, templating is safe and predictable. That's my two cents, I'd love to see the other pieces of feedback from the community focused on tradeoffs and expectations for opinionated web frameworks. |
Allowing users to pick either React or a Rust based frontend framework at the same time seems like the most inclusive option. I know that this would increase the complexity which goes against the idea of minimalism, however react ecosystem is mature, well supported in many ways. In my opinion, this approach would probably catch attention of more developers. As @jondot said,
could be a mistake moving forward. At the moment, attracting more developers seems like the better decision. |
I started thinking that React was the obvious choice for this, but after reading a lot of the comments about the complexity it would add I think I would like to see htmx as the de facto template and a rust frontend for type sharing if needed. It would be nice to be able to go either way on this depending on page complexity. If the user really wants to use react I'm sure that you would use loco as an api with your front/full stack of choice. |
I'm distilling some more of the feedback:
|
if you decide to support htmx and have templates, consider supporting template fragments w/ whatever your templating solution is: https://htmx.org/essays/template-fragments/ this makes it much less annoying to decompose a view into dynamically updated bits by avoiding template file blowout. |
also suggest supporting both a hypermedia API & a JSON API on different end points easily: |
Are there any big "in the wild" uses of htmx? |
hgtv/food network is starting to use it: https://www.foodnetwork.com/holidays-and-parties/photos/top-holiday-cookies some others: https://light.berkeley.edu/nobels/ mistral is using it: https://jobs.lever.co/mistral/586bc657-f593-4a1e-90c6-06ca3838d5a5 there's a webring here: but it's not backed by any of the big tech companies. I know one FAANG that is using it for internal tools, but can't say which. |
Thanks! Some more community updates from Loco:
Edit:
|
some other alternatives if you want a hypermedia-based front end lib out of the box:
we also have a book (free online) if you want some background philosophy on the hypermedia approach (esp. the first two chapters): and we have a #rust-htmx channel on our discord if you want to talk to rust users who have worked w/ htmx. Obviously severe selection bias, but maybe useful for practical experiences: |
We created an example of how to serve/develop a front-end app with Loco. It will be greate to get your feedback. |
I would vote for starting with htmx. I could be wrong but most of the folks who will adopt Loco will be mostly backend developers trying to build a full-stack app or SaaS so making frontend development easier will be really helpful. Rails is pushing for that as well with hotwire and even plain old CSS |
Hi, This is only a problem when building customer facing application because the current UX expectations from the users, and normally a rich UI + API will be the way to go. And this is already supported (API side) |
Maybe Look into Slint UI. It's a language (kinda) for creating ui for Slint apps. The UI written in Slint supports adding logic in rust or any other language and it gets compiled natively to system. It's syntax approach is almost like flutter, hence it would also improve productivity. Though people have to learn a new tool, it's pretty easy to learn. |
For Leptos, I think it's better to contribute to their end since they have templating mechanism for each web framework (currently actix and axum). So, Loco can just focus providing the backend and let Leptos handle the frontend matters. That should be much flexible. References: |
I agree here, found loco by searching "rails for rust". I was looking specifically for something that would allow me to iterate fast without fussing too much about the UI stack. Almost expected the project to use something like https://github.com/Keats/tera for the templating out of the box. The whole alure for me is the speed and productivity gains that can be had. Think Rails for Ruby or Phoenix for Elixir. Server side rendered templates feels like the only missing big piece from "Rust on Rails". |
hey @stefan-vatov, |
I don't want to just leave a +1 but loco supporting templating/htmx is literally the only reason I will go back to doing frontend development after 10 years of avoiding it like the plague because of the javascript hell it turned into. Really looking forward to this. |
+1 for templating support to be able to use htmx |
If you want to see how server side rendering will look like it is in master here: f6fae06 |
Very exciting! With your framework, rust has reached a new level of versatility. Keep up the good work |
The version was released 0.3.1 |
Views are now out! It should cover all bases. Anyone who wants to experiment with HTMX is now welcome. This should enable using HTMX more easily. |
This iteration looks fantastic. Great work, everybody. I want to share some thoughts as a polyglot engineer that's having a difficult time finding satisfaction in any ecosystem. Places that I see view logic being done elegantly:
astro's pagesremix routesblazor's route templatestanstack router - typesafe routingThings that I see lacking in some/all places:
It looks like |
htmx is a good choice, and if it can be like templ, there can be
|
The best approach is one where the front-end is written in something that's somewhat native to the front-end but still allows for static typing. |
I hope this doesn't come across as a shameless plug, however I might have a solution for the remark by @jondot :
I've created a small library called in-vite today. Which allows you to integrate Vite bundle's into your Rust backend (both during development and production). It even implements the necessary traits to use it with Tera templates:
The function A small bare-bones example with for Axum & Tera using Tailwind, AlpineJS and Typescript via Vite can be found here. Note, that this is my first public Rust library and thus might be a bit rough around the edges. Your feedback is welcome. |
Personally, I would like to stick as close to Ruby on Rails as possible. I really like the direction of Ruby on Rails version 8. Things like Hotwire, frames, etc mean you don't need to have heavy front end framework. I like this. I feel the direction of frontend architectures are going very complex with SSR and Hydration, etc. If you watch the Ruby on Rails 8 keynote, think you can see a much better approach, especially when we consider "one man" projects. |
Hey there. I feel like this would be a pretty good place to find people using Tera and potentially htmx together ;) I'd like to make it easier do complex templates in the next version of Tera as well as making it easier to integrate with htmx/livewire-like things with more targeted re-renders (block/component level). In practice this means adding the concept of components to Tera (similar to React/Vue/Solid etc) to replace macros (which are almost the same thing). The goal being to make a template engine where making complex UI feels as easy as React/JSX. If that sounds interesting, I would love some feedback on Keats/tera2#51 (and any other Tera feature request tbh, this is the right repo to ask) |
@Keats |
Currently Loco offers html output as a starting point for UI. We have decided to not decide about frontend, so that we can focus the thinking on it separately, and now have come the time to start thinking about frontend :)
Principles:
Insights
Output of this task Answer the questions:
The text was updated successfully, but these errors were encountered: