[HN Gopher] Rust needs a web framework for lazy developers
       ___________________________________________________________________
        
       Rust needs a web framework for lazy developers
        
       Author : dcminter
       Score  : 75 points
       Date   : 2024-10-06 21:21 UTC (1 hours ago)
        
 (HTM) web link (ntietz.com)
 (TXT) w3m dump (ntietz.com)
        
       | dartos wrote:
       | Isn't there a rust rails clone?
       | 
       | Yeah, it's called loco https://loco.rs/
       | 
       | FWIW I prefer the pile of libraries. Big frameworks are good for
       | scrappy startups trying to push their product out asap, but in
       | most of situations, I'd like a lower abstraction system to build
       | on.
        
         | hermanradtke wrote:
         | Rails clones in modern languages don't get wide adoption. I
         | wrote about why I think that is: https://hermanradtke.com/why-
         | your-rails-like-framework-is-no...
        
           | paradox460 wrote:
           | For what it's worth, Phoenix is quite rails like, as is the
           | ash framework, and both are quietly popular
        
       | paulgb wrote:
       | I was surprised not to see Rocket (https://rocket.rs/) mentioned
       | among the frameworks the author listed; I haven't used it myself
       | because I _like_ the more unopinionated axum/actix-web, but as I
       | understand it its goals are much more in the vein of what the
       | author wants in a batteries-included framework and it's been
       | around for a while now.
        
         | wslh wrote:
         | I 100% agree. I'm just a casual multi-language programmer these
         | days, but I'm familiar with Rocket.
        
       | henning wrote:
       | Whatever you do, don't make this an RFC in a Rust repo/something
       | up for debate and discussion. 500+ messages and literally years
       | later, no one will agree on a single thing. Just make the thing
       | you want and if people don't like it, they can stick with Actix.
        
       | BikeShuester wrote:
       | I'd rather see Crystal on Rails. Combines the elegance of Ruby
       | with the performance of a compiled language. And of course: macro
       | support.
        
       | godisdad wrote:
       | If the post were C++ focused instead of Rust would it make the
       | same, more or less sense?
       | 
       | A systems language with a high cognitive barrier to entry,
       | compile times and less than a decade of wide adoption can't
       | reasonably be expected to compete with something like Rails in
       | terms of approachability
        
       | doctorpangloss wrote:
       | For new web applications, why recommend alternatives to Next.js?
       | 
       | How do you convince someone to use an alternative? The knowledge
       | needed to understand why will help you get close enough in
       | Next.js anyway.
        
         | johnny22 wrote:
         | Next.js is not nearly flexible enough. I'd never use it. It
         | feels like rails, but somehow even more tightly coupled than
         | that.
        
         | googledocsftw wrote:
         | 1. Lots of dead ends. Fetch cache limit for example. Cant
         | replicate prod page caching behaviour in dev. Etc. Many issues
         | with 100 thumbs get abandoned.
         | 
         | 2. NodeJS. Not everyone likes it.
         | 
         | 3. It is slow. Yes it is! Try to get good web metrics with Next
         | I dare you!
         | 
         | 4. Premature release of App Router. Will they do something like
         | that again.
        
           | doctorpangloss wrote:
           | I appreciate that you're getting to the crux of the matter
           | instead of downvoting.
           | 
           | In our experience elevating the web metrics in Next.js takes
           | the same expertise as doing it in any other framework. Our
           | experience with Vertx and Microsoft's dotnet web frameworks
           | have been good, but Next.js got us to a fast, featureful,
           | performant website sooner and with more flexibility around
           | requirements. I won't pass judgement on rust frameworks I
           | haven't used, but it's just to say that in an honest
           | accounting, a naked backend framework is less than half the
           | product when you're talking about web applications actually
           | worth making with original ideas. Unless you work at Google.
        
       | devjab wrote:
       | > I like to make silly things, and I also like to put in minimal
       | effort for those silly things. I also like to make things in
       | Rust...
       | 
       | I think this part is perhaps the silliest part of a very silly
       | article. If you really like to put in a minimal effort then why
       | on earth would you use Rust? If you want efficiency, memory
       | management and a compiled modern language just use Go. Then you
       | won't even need anything but the standard library for what you
       | want to do. Or... use Django as you suggest?
       | 
       | Yes, yes we use Rust in production because we thought it would be
       | easier (well safer) to teach to interpreted language OOP
       | developers than c/c++ but why on earth would you ever use it for
       | the web unless you are a member of the cult?
        
         | wongarsu wrote:
         | This is definetly something the article should have drilled
         | down on. Why Rust? I'm sure everyone's tired of hearing why
         | rust is an excellent alternative to c/c++ for new projects, but
         | as an alternative against Python it gets muddier. Rust has a
         | clear advantage in performance and memory footprint and a much
         | better multithreading story, but those are things that aren't
         | high priorities for 95% of web development.
         | 
         | That basically leaves you with Rust's type system. Rust's type
         | system is pretty great, and if we pretend we can't hear the
         | Haskell developers it's one of the best type systems out there.
         | That might seem to get in the way of quick prototyping, but on
         | the other hand it would mesh really well with a framework like
         | Django. One of the great things of Django was that you define
         | your data schema, and Django takes care of both the database
         | and a passable admin area. I'm sure you could greatly expand on
         | that principle, with data types driving a lot of behavior and
         | conveniences that the framework just handles for you.
         | 
         | Maybe a bit like .NET, but without the enterprisy coat of paint
         | and without putting dependency injection everywhere.
        
         | paulgb wrote:
         | The author is clearly building things for the joy of it. If she
         | gets the most joy from Rust, that's what she should use!
         | 
         | > See, if I want to make something for the web, I could use
         | Django but I don't want that. I mean, Django is for building
         | serious businesses, not for building silly non-commercial
         | things!
         | 
         | Personally, I spent the first decade of my career switching
         | between languages, believing that I should use the best tool
         | for any given job. I spent the last ~five years doing mostly
         | Rust, and I've learned that there's a level of mastery of a
         | language you can never quite reach if you're always context-
         | switching between them, especially a language as "deep" as
         | Rust. This means I write things in Rust that Rust is not the
         | best language for.
        
         | andrewxdiamond wrote:
         | > I also like to make things in Rust
         | 
         | Seems like a good enough reason to use it to me, but perhaps
         | I'm just another cult member.
         | 
         | > we use Rust in production because we thought it would be
         | easier (well safer) to teach to interpreted language OOP
         | developers than c/c++
         | 
         | I think rust is just safer period, regardless of your level of
         | expertise or background. Or are you saying that every memory
         | safety bug was written in by someone inexperienced?
         | 
         | Not to mention the concept of "sharing code." See I may write
         | garbage tier rust code that basically glues together a bunch of
         | libraries, many of those libraries are written by programmers
         | way better than me, and I can gain performance and safety from
         | using their work. The performance difference between languages
         | like Rust and JS is huge, even if I, tainted by my background
         | in Java, write dogshit code.
        
         | phoronixrly wrote:
         | What kind of logic is this... The Rust language is quite
         | rigorous, so web frameworks on it should also be equally
         | laborious to work with?
         | 
         | The person likes writing in Rust, and would like to have a
         | batteries-included web framework so they can tie together a web
         | app quickly on the language they like to use...
        
           | lovethevoid wrote:
           | If you find the language rigorous, a web framework can't
           | magically do away with that. It's genuinely illogical to
           | believe so. There are plenty of web frameworks on Rust that
           | are quite nice to use, but they are still Rust, with all its
           | shortcomings in the same way Django is still Python with all
           | its shortcomings.
           | 
           | What you're asking for is a DSL built on top of Rust for the
           | purpose of creating web apps.
        
         | lnxg33k1 wrote:
         | As a Linux user I've had to deal with these kind of people who
         | wouldn't use something new unless it was made the same of what
         | they're currently using, all my life, they just are not able to
         | get it
        
       | mifydev wrote:
       | There is https://shuttle.rs. Not only a framework but a tool that
       | can generate all the web boilerplate around it, sounds lazy
       | enough for me!
        
       | pmccarren wrote:
       | s/lazy/efficient/g :)
        
       | Barrin92 wrote:
       | If you want to make a silly, minimal effort hobby project simply
       | don't use Rust. I'm gonna be honest I don't understand this
       | entire genre of using extremely complex, highly optimized systems
       | languages for tools that don't need them. Your flow chart should
       | basically go like this:
       | 
       | "Do I need zero cost abstractions because I'm writing a
       | computationally expensive very serious project?" If the answer is
       | no use a garbage collected, runtime managed language.
        
         | kstrauser wrote:
         | I don't know about that. I already knew a little Rust last
         | month when I wanted to write a REST API server that would
         | benefit from being deployable as a single executable. I
         | probably spent a grand total of 2-3 hours researching which
         | framework to use (actix-web for me), reading the code, and
         | implementing the endpoints I needed. The end result ended up
         | looking an awful lot like a Python Flask app. The actual code
         | writing part of the project wasn't any more complicated than
         | using any other language might've been.
         | 
         | Learning Rust and learning web service programming at the same
         | time would have a steep curve. If you already know the basics
         | of Rust and have written web services before, writing a new one
         | in Rust needn't be stressful.
        
       | jknoepfler wrote:
       | I wish the author success in their endeavor, but Rust is pretty
       | far down the stack of languages I'd use to deliver a webserver.
       | 
       | I look at Rust for serving web-traffic and I see: dreadful
       | concurrency model (I will never voluntarily go back to
       | async/await after working in Golang), weak client library stories
       | (if I'm writing a service layer for a db, etc.), high barrier to
       | entry, thin overlap with the core Rust value proposition
       | (correctness around memory access, performance).
       | 
       | That's not even addressing the "what happens when my entry-level
       | dev has to write something that interops with a web framework
       | written in Rust." My heart can't take those code reviews, I might
       | as well just write that shit myself without a framework for all
       | the pain that's going to cause.
       | 
       | Note: I don't write a ton of Rust, for reasons that are maybe
       | kind of obvious. I reach for it whenever C seems correct, which
       | is rare but not never (for me).
        
       | elAhmo wrote:
       | Rust is not for lazy developers and there are other languages if
       | you want to put minimal effort in building things.
        
         | p1necone wrote:
         | I'm a lazy developer and I love languages with an "if it
         | compiles it works" feel. I'd much rather hack around in rust or
         | typescript with half my brain switched off and a beer in hand
         | and eventually get working software than hack around in
         | javascript with half my brain switched off and a beer in hand
         | and get more and more broken software until I eventually give
         | up.
        
           | RandomThoughts3 wrote:
           | Then just use Ocaml or F#. You are welcome.
        
           | 27theo wrote:
           | TypeScript sure, but Rust? Half your brain switched off?
           | There is a middle ground between unfettered madness and the
           | Rust compiler's strict regime. Maybe try Elm.
        
       | tightbookkeeper wrote:
       | "Slow" scripting languages worked in the 90s for the web and they
       | work even better for now, plus you have more to choose from. The
       | key is to shell out to other tools for heavy lifting, like a
       | database. Multi process architectures are where Linux really
       | shines.
       | 
       | Rust can fit in that picture, but it doesn't need to be routing
       | http.
        
       | axegon_ wrote:
       | There is one: Poem[1]
       | 
       | The author mentions flask but looking at the "What we need
       | section", I don't think flask covers those. I hate Djago with a
       | passion but if those are the requirements, I think Django is the
       | one that closely resembles what the author is describing. So Poem
       | is not a good candidate either in that regard. Poem is all in
       | all, something that closely resembles FastAPI, which is actually
       | a complement. I've tried half a dozen rust web frameworks and
       | they all come with a ton of boilerplate fiddling with the initial
       | setup. Which is a problem if you want to get things done fast. In
       | that regard, poem nails it. Yes, actix has a considerably better
       | performance but unless you are aiming for sub-30 millisecond
       | responses, then actix is not what you should be looking at to
       | begin with. Also if you crave a Pydantic, there is a crate that
       | sort of does that for you: https://crates.io/crates/poem-openapi
       | 
       | [1] https://github.com/poem-web/poem
        
       | the__alchemist wrote:
       | 100%! I love Rust, but I will still use Python for backends
       | because of Django. Rocket, Actix, Axum etc are more like Flask,
       | but without Flask's integrations for the services. I don't
       | understand why there are so many competing microframeworks; one
       | of them should have IMO pivoted to a Django-like a while ago.
        
       | delduca wrote:
       | What make rust better than any language when the bottleneck is
       | the network or the database?
        
         | yakshaving_jgt wrote:
         | The bottleneck is mostly developer hours.
        
       | yakshaving_jgt wrote:
       | Yesod has most of the things on this wishlist (though it's
       | Haskell, not Rust), and Yesod is generally awesome. I've been
       | working with it for the past several years, and I look forward to
       | the next several years with it.
        
       | perrohunter wrote:
       | The http server in the std library is one of the things Go got
       | right and improved it's adoption, rust needs something similar
        
       | aabhay wrote:
       | Rust has some great and useful web frameworks that are a joy to
       | use, once you understand what is going on. For example, in Axum,
       | they use traits cleverly to allow you to use dependency injection
       | the same way that fastapi uses it. But at least when I started
       | using it, that wasn't an insight made bluntly clear with
       | tutorials as good as tiangolo's. Instead, I had to piece it
       | together via examples in the axum repo as well as from watching a
       | youtube video.
       | 
       | Don't fear, Rust can be as simple and clever as any other
       | language. And the Rust core OSS developer community has spent at
       | least the last ten minor versions improving dev ex considerably.
        
         | CoconutMilk wrote:
         | Curious which YouTube video you watched that helped learn Axum.
        
       | rob wrote:
       | [delayed]
        
       ___________________________________________________________________
       (page generated 2024-10-06 23:00 UTC)