5 ms·
I've enjoyed what I've done with Axum thus far. I ultimately opted to use Leptos on top of it, so I don't really use it directly at this point. But it's neat.
by LeftHandPath 2y ago
I've enjoyed what I've done with Axum thus far. I ultimately opted to use Leptos on top of it, so I don't really use it directly at this point. But it's neat.
For a long time, I used PHP and JS/TS for web projects. Now I'm using Rust with Axum/Tokio/Tower/Hyper (web server), Leptos (SSR using "Islands" flag, which also allows WASM generation for front end; JSX-like syntax), and Diesel (ORM and query builder that expects you define your schema using raw SQL). (I also leapt from DB2, MySQL and MariaDB to PostgreSQL)
It's heaven.
- satvikpendem 2y agoIt's great, isn't it? I'm doing the same for my apps, with Rust as the backend with Axum and Diesel, except I'm using Flutter for the frontend and also flutter_rust_bridge for some Rust crates I want to use directly inside the Flutter frontend. I'm using Flutter as I'm making mobile apps primarily and I think it will take Rust based solutions a long time to get to feature and component parity with Flutter, it is simply a huge task to create a UI framework and component library from scratch, only a company like Google or Apple seem to be able to do so.
- cies 2y ago> It's heaven. Your welcome. PHP and JS/TS are SWE ghettos. The improvements that TypeScript React, Laravel or Drizzle (smart SQL builder for TS) give are great but none can fix the underlying problems that a really shitty programming language results in. I used to really love Ruby. But I now believe there's even better that's also totally free. Rust is really nice! Kotlin, OCaml and Haskell also have some amazing "doing it right" cultures, that leverage "stronger typing" techniques.
- LeftHandPath 2y agoI’ve always loved Haskell as well, although the most I did with it was writing a small language interpreter for a CS class. It’s amazing how much better major languages could be. They’re slowly getting better - I started out using PHP 5 at work, and the improvements since then (eg PHP 8.4) are HUGE. I’ve used modern C++ extensively as well. I love Rust more than either. If you like Ruby, Loco RS is really neat as a(n immature) Ruby on Rails replacement.
- cies 2y agoWhile the improvements can be huge, they can never truly fix a language imho. There's too much code depending on it, and there's the stdlib that contains a lot of the "worst practices". It's easy to love Rust (OCaml, Kotlin, ...) more. > If you like Ruby Nah, only for very small throwaway script. And even for them I prefer Kotlin nowadays (stronger typing, better IDE integration, etc.)
- herewulf 2y agoAbsolutely a game changer. I'm using the same stack (minus Diesel) and I love that if it compiles it almost always works. Not so with JS/TS. With server functions (and of course client/server in the same codebase/language) I also finally get why anyone would be attracted to running JS/TS on the server side.
- LeftHandPath 2y agoThe only hitch was figuring out how to get server side includes not to break the WASM compilation (the solution was adding #[cfg] and #[cfg_attr] guards around the diesel use and derive rules). Other than that, it just worked - it’s so damn easy! I always thought WASM would be difficult to use. With Leptos, it’s easier than JavaScript.
- the__alchemist 2y ago> I love that if it compiles it almost always works I'm going to dig in a bit here: What do you mean specifcally by this? It is quite the claim! I suspect it has to do with meaning there is a low likelyhood of crashing, e.g. no type errors at runtime. My skepticism is that that general statement implies more than this.
- bb88 2y agoIs it because the types and memory issues have been sorted out during the compile phase meaning code will "run" without crashing? That doesn't mean the code will work (infinite loops, etc), but it will run, right? I've seen more than one Java program that will compile, but will throw a NullPointerError that gets unhandled.
- rapsey 2y agoYes. Quite often you spend hours working on something and when you run it the first time it just works. This is one of the major reasons people fall in love with Rust. There are just very ugly surprises or runtime issues. If it compiles it runs.
- nostradumbasp 2y agoHow are you liking Leptos? I've been on the fence of trying Leptos vs Dioxus for a new project. They both seem great, but when I look for things like "charts" or "plots" or other components I don't see much support. Even though I am not a fan of TS I'm not sure if I really want to make those components myself.
- LeftHandPath 2y agoI liked the Leptos JSX syntax and I feel like Dioxus is addressing a different problem. Dioxus specifically markets itself as a tool for universal app development. I looked at it, Perseus, Askama + JS, etc, but ultimately thought Leptos seemed like the best to dive in with. For charts and plots -- I was thinking about the same thing today, actually! I've usually done those manually with SVG and JS. I was wanting a framework, and spent 30 minutes or so today looking at tools to use R diagrams on the web [0]. Also thought a little bit about making my own library. There are existing libraries like Plotters that should plug and play with Leptos just fine [1], but I haven't tried any yet. [0]: https://m-clark.github.io/webR/visualization.html https://m-clark.github.io/webR/visualization.html [1]: https://docs.rs/plotters/latest/plotters/ https://docs.rs/plotters/latest/plotters/
- satvikpendem 2y agoI just saw this on r/rust today, a library called plotlars got a release (not to be confused with plotters). https://www.reddit.com/r/rust/s/QG21lu2Oy4 https://www.reddit.com/r/rust/s/QG21lu2Oy4
- nostradumbasp 2y agoLooks pretty nice. The default style has some perks over plotters. Not throwing shade, it just looks nice. Thank you for sharing.
- nostradumbasp 2y agoThanks for chiming in. If there was a way to embed R plots without a lot of pain or CPU cycles server-side that would be fabulous. I would love to see an example of that. Plotters is pretty decent, I've used and abused it in a few projects over the years. But if I wanted something dynamic, I'm not sure how well that might go. It does look like SVG and JS would be the way to go. Maybe there's a nice trick there, not sure.
- karlmdavis 2y agoI almost gave up on Leptos, because I was trying to use it with Actix, which it supports less-well than it does Axum (and I’m too stubborn for my own good and wouldn’t switch). I came back to it recently after the Leptos 0.7 release, though, and it’s MUCH smoother. Still early days for a framework like this, but I think it’s got a lot of magic.
- mvelbaum 2y agoCan you talk about about performance implications of using WASM? 1. The browser needs to load the whole app before anything else could be done resulting in a slow first load. 2. WASM -> DOM manipulation is slow.
- LeftHandPath 2y ago1: Actually, that's not true! I use Leptos in their "islands" mode for server side rendering. The entire page is sent as an HTML response, and there is little/no "hydration". The WASM file ONLY includes interactive "islands" that are explicitly marked with the #[island] attribute [0]. In other words, the server binary is handling most of the rendering, similar to if I used a templating tool like Askama or Tera. 2: Leptos is generally slower than vanilla JS, I believe for that reason, but comparable to major JS frameworks [1, 2]. [0]: https://book.leptos.dev/islands.html https://book.leptos.dev/islands.html [1]: https://krausest.github.io/js-framework-benchmark/current.html https://krausest.github.io/js-framework-benchmark/current.ht... [2]: https://leptos.dev/ https://leptos.dev/
- klaussilveira 2y agoWhat about event listeners that are supposed to listen to elements inside the islands? Like clicks, key ups, etc. Who handles that?
- throw10920 2y agoSo what's your iteration time like? I've always gotten about 2 seconds between making a change and testing it out with other web servers - curious as to how long it takes with Rust.
- LeftHandPath 2y agoOn my laptop (2017 macbook air with an i3 and 8GB ram), about 45 seconds. On my desktop (Ryzen 5600G, 32GB ram), 2-15. I haven't tried any techniques to reduce the compilation time yet.