Live data from Hacker News

Rust needs a web framework

ntietz.com

101–110 of 395 posts

Re: Rust needs a web framework

#101
post #46

Earlier quoted context omitted.

Counter-point: developing web services in Rust is just as easy as doing it in Go or Java, yet you now have an excellent type system (sum types!), an excellent package manager, and extremely good performance. You can do dependency injection in Rust to share connection pools just like you would in Java, and it's super simple to write threaded background tasks. Google gave a talk recently that said they measured Rust de…

The developers they measured, were they using the languages for the exact same tasks? Otherwise it's just stating that they assign the languages to categories of problems they are equally efficient in.

https://www.youtube.com/watch?v=QrrH2lcl9ew

> "We have at this point rewritten a large number of systems [..] have some very concrete things that we can say"

> "When we've rewritten systems from Go into Rust, we've found that it takes about the same sized team about the same amount time to build it. [...] no loss of productivity when moving from Go to Rust."

> "We do see some benefits [...] we see reduced memory usage in the services that we've moved from Go. [...] We see a decreased defect rate over time in those services that have been rewritten in Rust"

> "Within two months about a third of the folks were feeling as productive, within four months about 50%."

> "People do indeed feel as productive in Rust as they do in their original language. C++, Java, Python, Go."

> "One of the biggest latencies is code review time [...] How hard is it to review code in Rust? [...] A little over half said that Rust is easier to review. The most incredible question [...] The confidence that people have in the correctness of the Rust code that they're looking at. [...] 85% of people believe that their Rust code is more likely to be correct."

Re: Rust needs a web framework

#102

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 c…

I write my hobby projects because writing them is fun. I don't find writing Ruby, Python, Go, and a host of other so-called "more appropriate" languages fun.

If someone enjoys writing Rust, it's natural that they'll reach for it when they're looking to write something for fun. If the tools/libraries in that language exist to make writing a particular type of thing more fun or easier, then more the better.

Re: Rust needs a web framework

#103

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 pr…

> dreadful concurrency model (I will never voluntarily go back to async/await after working in Golang), Rust supports golang style message-passing concurrency if you want it[1]. I'd argue Rust mpsc channels are actually more powerful than Golang's and add richness to message-passing concurrency modeling. [1]: https://doc.rust-lang.org/book/ch16-02-message-passing.html

Yeah, I don't get the hate here. Rust's channels are just as powerful as Go's, and there are even implementations of them in the futures crate that implement the Future trait, so you can await on them and effectively get the same behavior as "blocking" on a channel in a goroutine, without having a bunch of blocking native threads.

Re: Rust needs a web framework

#104
post #87
post #10

> 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 stan…

I am a fan of Rust for systems programming, but so many people are using Rust for things that are nothing even remotely close to systems programming. So many projects you see being written (or rewritten) in Rust are projects where I just think 'wait, why can't this just have a GC'? And then you look at the code base, and it's all Arc >s, and you can't help at marvel at this, since that's just GC, so what's the benefi…

I'm just really leery of using languages that don't have a clear separation between immutable and mutable state. Having it in Rust catches so many bugs.

I also want to write code in languages where you don't have to engage in bad software engineering practices to get optimal performance. That usually means aggressive inlining, something that Rust excels at.

edit: the other thing I wanted to mention is that rust's features cause dependencies to be pretty high quality.

If I pass in a slice of something, I'm no longer worried that something ten layers down will change it.

Error handling is explicit and panics are rare, so I'm not worried that dependencies will start throwing exceptions after an update. (This is the reason functions should indicate errors in type signatures—a better ecosystem.)

ADTs mean dependencies represent fewer illegal states internally.

It's just really nice to write code where the bugs are a couple levels up from bullshit like this.

Re: Rust needs a web framework

#105
post #10

> 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 stan…

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 b…

For what I hack on I often run into issues with the FFI performance between go/c# c/c++. I’d rather not write C or C++ and Rust is one of the few languages that allows me to mess around with obscure libs at native performance and yet slap a web interface in front of it. cxx/bindgen is stellar in how fast they allow you to wrap libraries. These cases is where I would want like the simplest most opinionated web framework (like gin in Go).

For everything else, there’s Go IMO.

Re: Rust needs a web framework

#106

Earlier quoted context omitted.

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.

Show me where I asked for a framework that magically turns Rust into Ruby. The person has created a list of (high-level!) features that they need. None of them are 'no borrow checker'.

I reckon "Rust on Rails" would be a great idea.

It'd be cool to have an out of the box "90% of what a website needs" toolkit that means writing your 10% custom code/secret-sauce in a modern code security obsessed language. Even if it is opinionated and "batteries included" in ways that make some things annoying.

I have built many projects that start with a WordPress install, to piggyback it's CMS, user management, and admin backend. I then inevitably end up making a choice between writing the project in php, or jumping through hoops to use the WP features (like auth and user accounts) in some other language that's more appropriate to the task at hand.

Re: Rust needs a web framework

#107

I guess I'm just "weird" for thinking the laziest and least error prone way to write a web app is in plain javascript? Any framework is too much extra work to learn and going to eventually get you shot in the foot.

Least error-prone and JavaScript in one sentence, I’m not sure about that, to be honest. JavaScript alone without any types in a big project is a shot in the foot, let alone the quirks JavaScript has. Apps crash when a thrown error is unhandled, etc.

I would say JavaScript is easy, but it’s definitely not the type for a least error-prone app.

Re: Rust needs a web framework

#108

Earlier quoted context omitted.

The answer for why folks are so inclined towards doing high-level tasks in Rust... is the type system. Its sensibilities are in a sweet spot that makes it very easy to pull off huge refactors. It was also a lot of people's first introduction to algebraic data types being used in nearly all error handling (its usage of `Result where E implements Error` and lack of nulls or exceptions). It makes a lot of progress towar…

> The answer for why folks are so inclined towards doing high-level tasks in Rust... is the type system. TypeScript has an equally powerful type system. Python's type system is almost as good. Both have are significantly more productive when it comes to writing software, and have bigger ecosystems and lower learning curves. > It makes a lot of progress towards the goal of "make invalid states unrepresentable", which…

> TypeScript has an equally powerful type system.

How does TypeScript's type system prevent shared mutable state?

Re: Rust needs a web framework

#109
post #90

Earlier quoted context omitted.

> 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 s…

> 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? I think you're reading too much into that and creating conflict where there isn't any. GP just meant that they had a bunch of interpreted language OOP developers (probably Java or C# or something like that), and they wanted them to start writ…

Also, without claiming that experienced c/c++ developers never write memory safety bugs, I don't think it's at all controversial to say inexperienced c/c++ developers write a lot of them (and hopefully experienced ones write way fewer).

Re: Rust needs a web framework

#110

Earlier quoted context omitted.

> The answer for why folks are so inclined towards doing high-level tasks in Rust... is the type system. TypeScript has an equally powerful type system. Python's type system is almost as good. Both have are significantly more productive when it comes to writing software, and have bigger ecosystems and lower learning curves. > It makes a lot of progress towards the goal of "make invalid states unrepresentable", which…

> TypeScript has an equally powerful type system. How does TypeScript's type system prevent shared mutable state?

When did threading get added to JavaScript?

And does Rust have type unions and intersections, interfaces, and mapped and conditional types?

Post reply on HN