Live data from Hacker News

Rust can be difficult to learn and frustrating, but it's also very exciting

influxdata.com

21–30 of 282 posts

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#21
I've learned a bit of Rust recently but then started programming in Go. Now that I've learned a decent amount of Go I'm thinking of giving Rust another try, because Go has so many obvious weaknesses.

However, I'm still torn between those languages, which I both consider as fancy alternatives to C++ with a growing amount of libraries and community support. I neither like Go nor Rust, but learn them to keep up to date and because I need something with good tooling and many libraries that creates compact and fast executables. Rust still seems overly complicated to me, though, and I say that as someone who enjoys programming in Ada.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#23
post #18

I've enjoyed learning Rust, but I'm at the stage where I'm hitting constant stumbling blocks because of the slightly niche nature of what I'm doing. It's the ugly side of Rust; when you're stuck with a series of problems that you can't solve (or take too long to solve), when there aren't enough people in the community to help you, and you end up being unproductive for a while. Where I've seen small projects to their…

Great job in pushing through though. Where have you been posting for help, I am no ways an expert, and have been learning Rust, but all I have heard is the welcoming nature of the community, and would love to at-least try and help. Its a great language, but yes, a stabilizing and emerging ecosystem. But this is the way it will mature; implement tasks that push the language and hopefully come out with good solutions. The Go ecosystem evolved in this manner as-well, and others as well.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#24
post #18

I've enjoyed learning Rust, but I'm at the stage where I'm hitting constant stumbling blocks because of the slightly niche nature of what I'm doing. It's the ugly side of Rust; when you're stuck with a series of problems that you can't solve (or take too long to solve), when there aren't enough people in the community to help you, and you end up being unproductive for a while. Where I've seen small projects to their…

Usually someone will help you out on irc or on the rust subreddit, but I think your point may still stand.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#25
post #20
post #15

Earlier quoted context omitted.

I kinda felt similarly until I found one of my existing web services wasn't quite fast enough (currently serving around 1000req/s at peak). I could either go for a third rewrite in yet another framework hoping to increase performance by maybe 30%, or I could try something entirely new. First attempt with rust more than doubled performance of the existing system on the same hardware. Now I feel a need to learn more.

What are you serving? Some of the Rust frameworks for backend should be able to do more than 1000req/s, but it depends what you're doing.

The system's peak _usage_ is 60kreq/min (avg 1k/s), the Python code it's written in can handle maybe 850/s per instance at 100% CPU.

Rust is fine, rust is managing almost 2k/s on the same hardware. And this is when I know practically nothing about Rust, I expect I'm likely able to do better given time.

It's acting as a simple filter and cache over JSON data on Postgres.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#26
post #4

Can anyone recommend exercises for learning a new language. For example, something like "implement a class with these methods", or implement a function that does this. Something that is realistic, should only take an hour or two to implement for a competent programmer, requires you to learn more complicated features of a language, yet I can finish before getting bored or frustrated?

Maybe replace something you would write as a shell/perl/python script for automation with a rust binary.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#27

Earlier quoted context omitted.

you may want to have a look at Rocket https://rocket.rs/ , you won't be disappointed

Rocket requires the nightly Rust compiler, which isn't something I find acceptable for production applications, and it's synchronous, so it's really slow. I have been rather disappointed by what I perceive as the author's unwillingness to work towards stable Rust. They have a GitHub issue where they track all of their dependencies on nightly, and kind of just say they aren't going to do anything about it -- it's up t…

It's not that he's unwilling to make it run on stable, it's that he has to sacrifice ergonomics to make it run on stable. Despite it not being async, yet, Rocket is my go-to because it has the best ergonomics. Something like actix-web may be more performant, but it's ergonomics are poor in comparison.

Regardless, Rust is stabilizing procedural macros which just leaves the never type as the last stabilization required for Rocket to be able to run on stable Rust. Additionally, I believe their next release is targeting the rewrite to async. A lot of it has to do with Rust firming up its own story around async.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#28
post #4

Can anyone recommend exercises for learning a new language. For example, something like "implement a class with these methods", or implement a function that does this. Something that is realistic, should only take an hour or two to implement for a competent programmer, requires you to learn more complicated features of a language, yet I can finish before getting bored or frustrated?

I'd also like to hear what others do to learn languages. I like to write a little RPN calculator. The program's interface might vary depending on the language: to learn browser JS, you might do a DOM-based UI; for Rust it might be a CLI; for Go or Erlang maybe a line-oriented network service. Depending on the interface, this tends to exercise language and runtime features like: string handling and parsing, event hand…

I usually write data structures like Linked Lists when learning a new programming language.

This was a critical mistake for me when learning Rust and led to many, many stumbling blocks

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#29
post #18

I've enjoyed learning Rust, but I'm at the stage where I'm hitting constant stumbling blocks because of the slightly niche nature of what I'm doing. It's the ugly side of Rust; when you're stuck with a series of problems that you can't solve (or take too long to solve), when there aren't enough people in the community to help you, and you end up being unproductive for a while. Where I've seen small projects to their…

Usually someone will help you out on irc or on the rust subreddit, but I think your point may still stand.

It depends, my biggest struggle right now is with the tokio/futures ecosystem, so I'm on gitter::tokio quite a bit, and have posted once on /r/rust.

With patience, I eventually solve many problems, but the lead-time is costly. Plus when I'm doing something wrong in my code, rustc could take over 5 minutes compiling, and then come back complaining. Even when I find someone willing to help me debug, the process takes a few hours, and I end up feeling bad for wasting someone's time.

Re: Rust can be difficult to learn and frustrating, but it's also very exciting

#30

Earlier quoted context omitted.

Rocket requires the nightly Rust compiler, which isn't something I find acceptable for production applications, and it's synchronous, so it's really slow. I have been rather disappointed by what I perceive as the author's unwillingness to work towards stable Rust. They have a GitHub issue where they track all of their dependencies on nightly, and kind of just say they aren't going to do anything about it -- it's up t…

It's not that he's unwilling to make it run on stable, it's that he has to sacrifice ergonomics to make it run on stable. Despite it not being async, yet, Rocket is my go-to because it has the best ergonomics. Something like actix-web may be more performant, but it's ergonomics are poor in comparison. Regardless, Rust is stabilizing procedural macros which just leaves the never type as the last stabilization required…

> It's not that he's unwilling to make it run on stable, it's that he has to sacrifice ergonomics to make it run on stable.

Two sides of the same coin. I clearly disagree about the amount of ergonomics that would have to be "sacrificed" in order to make the library usable in a production environment (on stable). So, it's simply an unwillingness to bring the library to stable, from my point of view.

Take Tower Web for example: https://medium.com/@carllerche/tower-web-0-3-async-await-and...

This has very similar ergonomics to Rocket in that it allows decorating handlers with their route, but it runs on Stable Rust. If you want to use `async fn`, that requires nightly for now since that's literally the nightly syntax for an async function, but the route decorators work on stable. As I previously mentioned, Tower Web is not mature, so I would not recommend it at this stage, but it shows what is possible.

I don't personally think that decorating handlers with routes is significantly more ergonomic than defining a table of contents somewhere else, like Actix does it. Defining routes is usually a very small part of your code that you do once and move on. Beyond that, what ergonomics are we talking about?

Actix can easily and automatically deserialize JSON into structs, for example: https://actix.rs/docs/extractors/#json

Post reply on HN